Created
November 21, 2017 11:08
-
-
Save shangdev/6eecd08d41d6ae1a1f7e5508fb119c41 to your computer and use it in GitHub Desktop.
linux后台运行和关闭、查看后台任务
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 把命令放到后台执行 | |
$ nohup sh rsync.sh & | |
# 正在前台执行的任务放到后台,并且处于暂停状态 | |
$ ctrl + z | |
# 查看后台运行的任务 | |
$ jobs | |
# 调用后台的任务至前台 | |
$ fg | |
$ 如果有多个,使用fg %jobnumber(命令编号) | |
# 将一个在后台暂停的命令,变成在后台继续执行 | |
$ bg | |
$ 如果有多个,使用用bg %jobnumber(命令编号) | |
# kill任务 | |
$ 通过jobs命令查看job号(假设为num),然后执行kill %num | |
$ 通过ps命令查看job的进程号(PID,假设为pid),然后执行kill pid | |
# 如果在另一个终端打开,使用以下命令查看并使用kill pid干掉进程 | |
$ ps aux | grep "rsync.sh" (a:显示所有程序 u:以用户为主的格式来显示 x:显示所有程序,不以终端机来区分) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment