3

我试图找出脚本中减慢整个过程的点。我正在使用 expect 脚本发送一个 sed 命令来搜索和替换文件中的一行。这需要 2 秒到 20 秒才能完成,而它不应该持续超过一秒。我是两个终端中并行的两个期望脚本。第一个文件launchmpj.exp启动一个 qsub 作业,该作业需要几秒钟才能启动。第二个文件launchneuron.exp等待 qsub 作业启动并继续执行脚本。当 qsub 作业启动时,launchmpj.exp发送一个命令,允许第二个文件launchneuron.exp知道 qsub 作业已启动并停止等待。

这里是launchmpj.exp

#!/usr/bin/expect -f
set timeout -1
spawn ssh $::env(username)@server
expect "$ " 
send "qsub -I -q berger -A lc_tb -l nodes=\$nbnodes -l walltime=24:00:00 -d .\r"
expect "$ "
send "cp \$PBS_NODEFILE node`sed -n '1p' nodequeue`\r"
expect "$ "
send "sed -i '/wait=on/ s//wait=off/' `sed -n '1p' qsubwaitqueue`\r"
expect "$ "
send "cd $::env(MPJ_HOME)/bin\r"
expect "$ "
send "sh $::env(MPJLAUNCH)\r"
expect "Process 6 ended"

这是第二个文件launchneuron.exp

#!/usr/bin/expect -f
set timeout -1
spawn ssh $::env(username)@server
expect "$ " 
send "set qsubwait = qsub`sed -n '\$p' queue`.sh\r"
expect "$ "
send "sh \$qsubwait\r"
expect "$ " 
send "set nodefile = node`sed -n '1p' nodequeue`\r"
expect "$ "
send "ssh `sed -n '2'p \$nodefile`\r"
expect "$ "
send "cd $::env(NEURON_HOME)\r"
expect "$ " 
send "nrniv -python $::env(NEURONPY)\r"
expect "$ "

作为该过程的一部分,我正在sed对下面的文件进行替换。单独的执行sed速度非常快,这意味着它不是上述脚本的瓶颈。但是,当从期望脚本完成时,这需要很长时间。

sed -i '/wait=on/ s//wait=off/' qsubwait.sh

文件qsubwait.sh

wait=on
echo "Waiting for qsub to start."
while [ $wait = on ]; do
eval `sed -n '1'p qsubwait.sh`
echo `sed -n '1'p qsubwait.sh`
done
4

1 回答 1

0

您是否达到了期望的超时值?运行您的期望脚本exp_internal 1以查看期望正在等待什么。

于 2013-07-27T14:47:22.993 回答