1. 程式人生 > 其它 >《詳解linux後臺、前臺執行程序》

《詳解linux後臺、前臺執行程序》

命令集合

command &  				  # 未啟動的command放入後臺去執行

[rootlocalhost ~~22:24:35]#ping baidu.com > /tmp/ll.txt &
[1] 3263






jobs                # 檢視後臺程序列表

[rootlocalhost ~~22:24:41]#jobs
[1]+  Running                 ping baidu.com > /tmp/ll.txt &






ctrl + z        	  # 暫停程序

[rootlocalhost ~~22:27:45]#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                  # 程式放入後臺執行,和 & 一樣

rootlocalhost ~~22:32:22]#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                  # 將後臺任務放入前臺執行


[rootlocalhost ~~22:22:23]#ping baidu.com > /tmp/ll.txt &
[1] 3241
[rootlocalhost ~~22:22:49]#fg 1
ping baidu.com > /tmp/ll.txt