linux前后台进程
命令集合
command & # 未启动的command放入后台去运行
[root@linux0224 ~]#ping baidu.com > /tmp/ll.txt &
[1] 3263
jobs # 查看后台进程列表
[root@linux0224 ~]#jobs
[1]+ Running ping baidu.com > /tmp/ll.txt &
ctrl + z # 暂停进程
[root@linux0224 ~]#ping baidu.com
PING baidu.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=49 time=7.01 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=49 time=7.32 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=49 time=7.29 ms
^Z
[1]+ Stopped ping baidu.com
bg # 程序放入后台运行,和 & 一样
[root@linux0224 ~]#bg 1
[1]+ ping baidu.com &
[rootlocalhost ~~22:32:46]#64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=49 time=6.70 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=49 time=7.20 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=6 ttl=49 time=7.04 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=7 ttl=49 time=6.95 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=8 ttl=49 time=7.05
fg # 将后台任务放入前台执行
[root@linux0224 ~]#ping baidu.com > /tmp/ll.txt &
[1] 3241
[root@linux0224 ~]#fg 1
ping baidu.com > /tmp/ll.txt

浙公网安备 33010602011771号