涉及到命令:
& fg bg jobs nohup ctrl+z ctrl+c
1.&
放在命令最后,功能是这条命令放到后台执行:
[jingsia@localhost asss]$ watch -n 1 date &
[1] 27289
2.jobs
查看后台运行的任务正在运行:
[jingsia@localhost asss]$ jobs -l
[1]+ 27289 Stopped (tty output) watch -n 1 date
3.fg
将后台的命令放到前台执行:
[jingsia@localhost asss]$ fg 1
watch -n 1 date
4.bg
将后台暂停的命令变为执行状态:
[jingsia@localhost asss]$ jobs -l #停止状态stopped
[1]+ 27563 Stopped nohup bin/Debug/Server.ASSS
[jingsia@localhost asss]$ bg 1 #唤醒
[1]+ nohup bin/Debug/Server.ASSS &
[jingsia@localhost asss]$ jobs -l #执行状态running
[1]+ 27563 Running nohup bin/Debug/Server.ASSS &
5.nohup
在后台执行,即使关闭终端也会继续执行:
[jingsia@localhost asss]$ nohup bin/Debug/Server.ASSS &
[1] 27563
[jingsia@localhost asss]$ nohup: ignoring input and appending output to ‘nohup.out’
6.ctrl+z
将一个正在执行的命令放到后台执行,并处于暂停状态
7.ctrl+c
将一个正在执行的命令停止
8.kill
杀死正在执行的命令