How do I script job submissions with dependencies?


Issue:  When scripting the submission of jobs, the job ID output by Moab will contain a newline character, which will cause problems if that output is captured and used as a dependency definition. 

Solution:  The newline character needs to be stripped from the captured job ID prior to using it.  As an example, consider the following:

$ JID=$(echo sleep 10 | msub)$ echo $JID$JID$JIDMoab.239 Moab.239 Moab.239echo "depend=afterok:$JID"depend=afterok:Moab.239

As you can see, the depend= will not be correct in this case.  To fix this, change it to add a line that fixes the job ID, as in the the following example:

$ JID=$(echo sleep 10 | msub)$ JID=$(echo $JID | sed -e 's/[[:space:]]//')$ echo $JID$JID$JIDMoab.239Moab.239Moab.239echo "depend=afterok:$JID"depend=afterok:Moab.239

 

For some reason, piping msub's output through "sed" did not seem to work, so use the above method. 

Tags: dependencies, script
Last update:
2018-08-29 18:54
Author:
Rob Greenbank
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags