拓展知識:linux後臺、前臺執行程序
阿新 • • 發佈:2022-03-23
1. 後臺執行任務調到前臺執行
# 1. 將任務放在後臺繼續執行
[root@server ~]#ping baidu.com > /dev/null &
[1] 33859
# 2. 檢視後臺任務列表
[root@server ~]#jobs
[1]+ Running ping baidu.com > /dev/null &
# 3. 將後臺執行任務調到前臺執行
[root@server ~]#fg 1
ping baidu.com > /dev/null
2.後臺暫停任務放到前臺執行
# 1. 執行ping命令後,使用Ctrl+z將前臺任務放入後臺暫停執行 [root@server ~]#ping baidu.com PING baidu.com (220.181.38.251) 56(84) bytes of data. 64 bytes from 220.181.38.251 (220.181.38.251): icmp_seq=1 ttl=128 time=7.31 ms 64 bytes from 220.181.38.251 (220.181.38.251): icmp_seq=2 ttl=128 time=44.1 ms ^Z [1]+ Stopped ping baidu.com # 2. 檢視後臺任務列表 [root@server ~]#jobs [1]+ Stopped ping baidu.com # 3. 使用bg命令將後臺暫停任務放入前臺執行 [root@server ~]#bg 1 [1]+ ping baidu.com & [root@server ~]#64 bytes from 220.181.38.251 (220.181.38.251): icmp_seq=3 ttl=128 time=7.42 ms 64 bytes from 220.181.38.251 (220.181.38.251): icmp_seq=4 ttl=128 time=7.84 ms