SSH会话中断

时间:2013-07-01 05:48:44

标签: unix ssh

我有一个项目,其中主服务器在4个从站(1 slave = master)上执行脚本。

所有4个奴隶并行使用&像这样的陈述:

sh /data/lpc/scripts/Remote_Execution/Python0/scrap_data_param.sh Python0 $Python0_ip &
  sh /data/lpc/scripts/Remote_Execution/Python1/scrap_data_param.sh Python1 $Python1_ip &
  sh /data/lpc/scripts/Remote_Execution/Python2/scrap_data_param.sh Python2 $Python2_ip &
  sh /data/lpc/scripts/Remote_Execution/Python3/scrap_data_param.sh Python3 $Python3_ip

脚本 * scrap_data_param * 与远程IP建立ssh连接,并在循环中运行各种命令。

我面临的问题是SSH会话完成并在完成特定SSH会话之前迭代下一个循环语句:

我已附上scrap_data_param.sh供您参考:

while read line
do
c="n"
for word in $line
do
if [ "$c" = "n" ]; then
 ssh $python_server_ip -n -p 1754 sh /data/lpc/scripts/remote_scraping.sh $word_match $word
done
ssh $python_server_ip -n -p 1754 sh /data/lpc/scripts/remote_matching.sh $word_match

done <'ssss.txt'

所以循环在完成一个语句之前迭代下一个ssh $python_server_ip -n -p 1754 sh /data/lpc/scripts/remote_matching.sh $word_match语句。

1 个答案:

答案 0 :(得分:0)

一个旧的学校书籍技巧可能是在你的连续命令之间留出足够的时间睡眠声明。

说像..

while read line
do
c="n"
for word in $line
do
if [ "$c" = "n" ]; then
 ssh $python_server_ip -n -p 1754 sh /data/lpc/scripts/remote_scraping.sh $word_match $word
 sleep 10;
done
ssh $python_server_ip -n -p 1754 sh /data/lpc/scripts/remote_matching.sh $word_match
done <'ssss.txt'