2012-03-10 67 views

回答

1

由于与由给定表达式所确定的状态的“测试”命令退出。

该命令在后台运行,但立即退出。

使用另一个命令,你会看到它在后台运行。

罗布

+0

例如在使用过程中催生了'睡100'。另外,请检查[nohup](http://ss64.com/bash/nohup.html)。 – 2012-06-15 02:03:52

1

的paramiko滋生每个.exec_command()一个线程,因此你不必因为如果你在bash添加常用shell魔术&。该.exec_command()将立即返回,你要仔细阅读其缓冲区(标准输入,标准输出,sterr)

client.exec_command('test > /dev/null 2 > &1') 
time.sleep(5) 
client.exec_command('killall -9 test') 
... 
# the remot command will be force killed if you close the channel. (may depend on sshd implementation) 

这将运行test重定向标准错误在spearate线程到标准输出。然后主线程进入睡眠5秒钟,另一个线程产生了杀死测试,或者如果你不杀它,你只需关闭通道和远程的sshd会照顾所有特效的会话

相关问题