I use bash version 3.2.51(1)
I work with job chains and want to start a new job when the old one is finished. So I check which jobs are currently running and only if the job number of the last run can not be found, a new job is to be submitted.
Here is the part of my script:
Job_ID=$(msub -E fvcom.pbs)
# test whether job is still running
CONTINUE="just started"
# do this loop, until the CONTINUE variable is empty (i.e. job is finished)
until [ -z "$CONTINUE" ] ; do
# wait $WAIT seconds
sleep $WAIT
# query if job is still running
RUNNING=$(./show_my_run)
echo $RUNNING
echo $Job_ID
# check whether specific job is still running
# then job ID is present in job overview
if [[ $RUNNING == *"$Job_ID"* ]] ; then
CONTINUE="Job_ID found"
echo $CONTINUE
else
CONTINUE=""
echo "Job_ID not found"
fi
done
The output is:
city.12345/1202110.batch.com kdd046 Running 4 00:59:14 Tue Jul 4
city.12345
Job_ID not found
Obviously I can see that Job_ID is present and the job is still running... The pattern is only recognized if there are several jobs running and the pattern is somewhere in the middle:
city.54321/1202133.batch.com kdd046 Running 4 00:59:14 Tue Jul 4 city.12345/1202110.batch.com kdd046 Running 4 00:56:19 Tue Jul 4
city.12345
Job_ID found
I also tried using
...
if echo "$RUNNING" | grep -q "$Job_ID"; then
...
but with same results.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire