我经常有这样的需求,通过ssh连接到服务器上,运行一个脚本。
因为脚本要运行很久,所以就丢在那里,看着打印输出。
一会儿不管他,电脑就进入休眠了,网络也就断了,ssh就断了,服务器运行的进程也挂了。
有没有什么办法,可以让这种情况下进程不死,然后再次练上去还可以继续看脚本运行的打印
巴扎黑2017-04-17 11:09:25
Ready to run
nohup xxx &
If already running
ctrl z pause
jobs See the id of the suspended task
bg id
disown id #Note: Without this sentence, the process will receive SIGHUP when the terminal ends. The default operation corresponding to this signal is to end the process
In addition to nohup, you can also use setsid, but the best thing is to use something like screen.
大家讲道理2017-04-17 11:09:25
Try nohup
nohup - run a command immune to hangups, with output to a non-tty
http://www.21andy.com/blog/20071121/6...
PHP中文网2017-04-17 11:09:25
This is because ssh has a time limit. If the client does not respond within a period of time, the server will disconnect.
Add
to /etc/ssh/ssh_config
ServerAliveInterval 60
One line and that’s it