2015年2月24日 星期二

登入後執行的指令 登出後仍然繼續運作: bg

使用時機:想遠端登入server, build一大包image, 然後就登出去做別的事

http://stackoverflow.com/questions/954302/how-to-make-a-programme-continue-to-run-after-log-out-from-ssh

You press ctrl-Z. The system suspends the running program, displays a job number and a "Stopped" message and returns you to a bash prompt.
You type the disown -h %1  command (here, I've used a 1 , but you'd use the job number that was displayed in the Stopped message) which marks the job so it ignores the SIGHUP signal (it will not be stopped by logging out).
Next, type the bg command using the same job number; this resumes the running of the program in the background and a message is displayed confirming that.
You can now log out and it will continue running..

BUT!!!

我照作之後失敗了...SIGHUP仍然關掉了程序
後來改用nohup
nohup [command] 成功留住程序

參考這裡研究 nohup 跟 disown 的差別
http://unix.stackexchange.com/questions/3886/difference-between-nohup-disown-and

沒有留言:

張貼留言