2016-11-29 87 views
0

我现在正在编写一个包含一些qsub作业的shell脚本,并在工作节点中进行并行处理,然后总结统计信息将被汇总并写入文件“temperature.txt”。但是,本地命令将在qsub登顶到节点之后立即执行。有没有什么像“wait [pid]”可以应用于qsub job id?如何在shell脚本中完成Grid Engine的qsub作业之后执行命令?

我的代码看起来像下面:

echo "Burning..." 
var=0 
while [ $var -ne 1 ] 
do 
    qsub -hold_jid update -t 1-$1:1 -N mcmc_bn_$T -S /bin/sh -j y -cwd ./bn_mcmc.sh # Submit mcmc 
    qsub -hold_jid mcmc_bn_$T -N update update.sh $1 
    T=$(tail -n 1 ./temp/temperature.txt) 
    echo $T 
    var=$(awk 'BEGIN{ print "'$T'"<1}') # when $T<1 => $var=1 
    echo $var 
done 

提前感谢!

Rui

+0

我相当熟悉R和我没有看到该标记的原因。 –

+0

@ 42-sorry为此标签。我的.sh脚本包含一些R脚本,我不加思索地添加它...... – RuyIBiostat

+0

使用'-e'结尾选项指定将在作业完成后运行的脚本。 –

回答

0

感谢大家参与讨论。

我发现通过脚本从溶液:http://ccn.ucla.edu/wiki/index.php/How_to_have_a_script_wait_for_jobs_before_proceeding

基本他/她写了一个脚本调用jobhold.sh检查qstat每隔30s(可以指定)。代码很简单,如下:

#!/bin/bash 
# jobhold.sh 
# JB 8/2010 
# usage: 
#  jobhold.sh qsub <my_command> 
#  jobhold.sh q.sh <my_command> 
# For commands that are submitted to cluster, hold until jobs have completed 
shopt -s expand_aliases 
sleep_time=30 # seconds; don't make this too short! don't want to tax system with excessive qstat calls 
me=`whoami` 
alias myqstat='qstat | grep $me' 
stdout=`[email protected]` # call the command and capture the stdout 
id=`echo $stdout | awk -F' ' '{print $3}'` # get the jobid 
status=`myqstat | grep $id` # check to see if job is running 
while [ -n "$status" ] # while $status is not empty 
do 
    sleep $sleep_time 
status=`myqstat | grep $id` 
done 

通过将这个脚本的命令之前,未来,所有qsub完成工作后,他们将被运行。如果您有其他想法或更有效的解决方法,请继续发帖。谢谢!

最佳,