Last active
May 11, 2017 14:17
-
-
Save olegs/563c9a17aa35d8625242cd1e7879233f to your computer and use it in GitHub Desktop.
Code to wait for the asynchronous tasks to finish on Portable Batch System using qsub
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
# Small procedure to wait until all the tasks are finished on the qsub cluster | |
# Example of usage: wait_complete $TASKS, where $TASKS is a task ids returned by qsub. | |
wait_complete() | |
{ | |
echo "Waiting for tasks..." | |
for TASK in $@ | |
do : | |
echo -n "TASK: $TASK" | |
# The task id is actually the first numbers in the string | |
TASK_ID=$(echo ${TASK} | sed -e "s/\([0-9]*\).*/\1/") | |
if [ ! -z "$TASK_ID" ]; then | |
while qstat ${TASK_ID} &> /dev/null; do | |
echo -n "." | |
sleep 100 | |
done; | |
fi | |
echo | |
done | |
echo "Done." | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The same code using
checkjob
instead ofqstat
is the following: