53
将正在运行的任务脱离终端运行
source link: https://www.tlanyan.me/make-running-task-detach-terminal/?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
转载请注明文章出处: https://tlanyan.me/make-running-task-detach-terminal/
让任务脱离终端运行,是非常容易做到的,常用的方法有两种: tmux
/ screen
,或者 nohup
。如果一个正在的运行的任务,因为网络或者时间关系,需要退出当前会话,如何让其在后台继续运行呢?答案是使用 disown
命令。具体操作如下:
-
按
ctrl + z
暂停任务; -
执行
bg
让其转入后台继续运行; -
输入
disown -h %jobid
让其脱离终端运行,其中jobid是用jobs
命令查看的后台任务编号。如果有多个任务,可以使用disown -a
命令.
disown
是 bash
内置命令,作用是删除当前shell的任务。如果你的shell不是 bash
,可能没有 disown
,则可以尝试 kill
命令组合达到相同效果:
kill -s SIGTSTP pid kill -s SIGCONT pid
参考
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK