-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates parsing and adds comments and output statements for logs
- Loading branch information
1 parent
81944eb
commit 61d688c
Showing
1 changed file
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
#!/bin/sh | ||
TODAY=$(date +"%d-%m-%y %H:%M:%S") | ||
DAY=86400 | ||
. {{ galaxy_root }}/.bashrc | ||
cd ~ | ||
for job in $(gxadmin query queue-detail --all | grep running | grep interactive_tool | awk '{print $3}') | ||
do | ||
# Get job working directory | ||
JWD=$(python3 /usr/local/bin/galaxy_jwd get $job) | ||
pushd $JWD | ||
ClusterID=$( head -n 1 job_condor.log | awk '{print $2}' | awk -F. '{print $1"."$2}' | sed 's/^(//' ) | ||
if [ "$(condor_q -global $ClusterID -autoformat JobStartDate)" == "undefined" ] || [ "$(condor_q -global $ClusterID -autoformat JobStartDate)" == "" ] | ||
then | ||
|
||
# Get external/Condor job ID from either external_id file or job_condor.log file from JWD | ||
if [ -f $JWD/external_id ]; then | ||
ClusterID=$(cat $JWD/external_id | tr -d '"') | ||
elif [ -f $JWD/job_condor.log ]; then | ||
ClusterID=$(head -n 1 $JWD/job_condor.log | sed -n 's/.*(\([0-9]*\)\..*/\1/p') | ||
fi | ||
|
||
# If cluster ID is found | ||
if [ ! -z "$ClusterID" ]; then | ||
# Check if job is running for more than 24 hrs and remove it | ||
if [ "$(condor_q -global $ClusterID -autoformat JobStartDate)" == "undefined" ] || [ "$(condor_q -global $ClusterID -autoformat JobStartDate)" == "" ]; then | ||
echo "Removing condor job $ClusterID (Galaxy job id: $job) on $TODAY" | ||
condor_rm $ClusterID | ||
|
||
elif [ $(($(date +"%s") - $(condor_q -global $ClusterID -autoformat JobStartDate))) -ge $DAY ]; then | ||
echo "Removing condor job $ClusterID (Galaxy job id: $job) on $TODAY" | ||
condor_rm $ClusterID | ||
elif [ $(($(date +"%s") - $(condor_q -global $ClusterID -autoformat JobStartDate))) -ge $DAY ] | ||
then | ||
condor_rm $ClusterID | ||
fi | ||
fi | ||
popd | ||
done |