要求:将一个正在当前前台执行的进程转入后台执行,并且要求退出shell后依然保持不退出进程。
-
ctrl+zto stop (pause) the program and get back to the shell
-
bgto run it in the background -
disown -h [job-spec]where [job-spec] is the job number (like%1for the first running job; find about your number with thejobscommand) so that the job isn't killed when the terminal closes
操作如下:
[root@dispatch_19 gcc-4.8.1]# cd /home/machen/vv_cold_algorithm/movie_score_builder && /usr/local/bin/python view_record_manage.py save 1
13-12-28 13:50:49 ./logs/view_record.log INFO start calculate delta data
13-12-28 13:50:49 ./logs/view_record.log INFO hdfs:/data/dm/recommend/recom_yvv/20131227
first fresh...
ctrl+z
[1]+ Stopped /usr/local/bin/python view_record_manage.py save 1
[root@dispatch_19 movie_score_builder]#bg
[1]+ /usr/local/bin/python view_record_manage.py save 1 &
[root@dispatch_19 movie_score_builder]#jobs
[1]+ Running /usr/local/bin/python view_record_manage.py save 1 &
[root@dispatch_19 movie_score_builder]# disown -h %1

本文介绍如何将前台进程转为后台运行,并确保即使在退出shell后进程仍能继续执行的方法。通过使用组合键Ctrl+Z暂停当前进程,接着利用bg命令将其转入后台运行,最后使用disown -h命令确保进程不会因终端关闭而被终止。

2413

被折叠的 条评论
为什么被折叠?



