暂停shell脚本直到上一个命令结束

时间:2015-10-30 16:46:49

标签: linux bash shell unix

我有一个shell脚本,其中有一个qsub命令,后面是其他命令,它依赖于qsub命令的输出。我有一个看起来像

的shell脚本
qsub <my_jobs>
cat <some_files>
grep <some_pattern>

我希望qsub在脚本转到cat命令之前完成运行。我把&#34;等等&#34;在qsub之后,但没有奏效。

1 个答案:

答案 0 :(得分:4)

将“-sync y”添加到qsub命令行。

来自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.