Ssank
Ssank

Reputation: 3657

pausing a shell script till previous command finishes

I have a shell script which has a qsub command follwed by other command which depend on the output of the qsub command. I have a shell script which looks like

qsub <my_jobs>
cat <some_files>
grep <some_pattern>

I want the qsub to finish running before the script goes to the cat command. I put "wait" after the qsub, but did not work.

Upvotes: 1

Views: 81

Answers (1)

olivecoder
olivecoder

Reputation: 2914

Add "-sync y" to the qsub command line.

From the manual in: http://gridscheduler.sourceforge.net/htmlman/htmlman1/qsub.html

 -sync y[es]|n[o]
      -sync y causes qsub to wait for  the  job  to  complete
      before  exiting.   If  the  job completes successfully,
      qsub's exit code will be that of the completed job.  If
      the job fails to complete successfully, qsub will print
      out a error message indicating why the job  failed  and
      will  have  an exit code of 1.  If qsub is interrupted,
      e.g. with CTRL-C, before the  job  completes,  the  job
      will be canceled.
      With the -sync n option, qsub will exit  with  an  exit
      code of 0 as soon as the job is submitted successfully.
      -sync n is default for qsub.

Upvotes: 4

Related Questions