shallow丿ove測試
[root@localhost ~]# cat 1.txt ls: cannot access 111.txt: No such file or directory 111: ls: cannot access 111.txt: No such file or directory 111: ls: cannot access 111.txt: No such file or directory 111: [root@localhost ~]# cat 1.txt | wc -l 6 [root@localhost ~]# cat 1.txt | grep '111' ls: cannot access 111.txt: No such file or directory 111: ls: cannot access 111.txt: No such file or directory 111: ls: cannot access 111.txt: No such file or directory 111:
crrk+z暫停一個任務code
[root@localhost ~]# sleep 1000 ^Z [1]+ Stopped sleep 1000
jobs查看後臺的任務進程
[root@localhost ~]# jobs [1]+ Stopped sleep 1000 [root@localhost ~]# sleep 2000 ^Z [2]+ Stopped sleep 2000 [root@localhost ~]# jobs [1]- Stopped sleep 1000 [2]+ Stopped sleep 2000
bg[id]把任務調到後臺後臺
[root@localhost ~]# bg 2 [2]+ sleep 2000 & [root@localhost ~]# jobs [1]+ Stopped sleep 1000 [2]- Running sleep 2000 &
fg[id]把任務調到前臺file
[root@localhost ~]# fg sleep 1000 ^Z [1]+ Stopped sleep 1000 [root@localhost ~]# jobs [1]+ Stopped sleep 1000 [2]- Running sleep 2000 & [root@localhost ~]# fg 2 sleep 2000 ^Z [2]+ Stopped sleep 2000 [root@localhost ~]# jobs [1]- Stopped sleep 1000 [2]+ Stopped sleep 2000
命令後面加&直接丟到後臺終端
[root@localhost ~]# bg 1 [1]- sleep 1000 & [root@localhost ~]# jobs [1]- Running sleep 1000 & [2]+ Stopped sleep 2000 [root@localhost ~]# fg sleep 2000 ^C [root@localhost ~]# fg sleep 1000 ^C [root@localhost ~]# jobs [root@localhost ~]# sleep 100 & [1] 3785 [root@localhost ~]# jobs [1]+ Running sleep 100 &
打開另外一個終端測試,jobs命令卻沒有顯示任何東西,能夠經過查看進程找到後臺運行grep
[root@localhost ~]# jobs [root@localhost ~]# ps aux | grep sleep root 3785 0.0 0.0 107908 612 pts/0 S 14:55 0:00 sleep 100 root 3787 0.0 0.0 112656 976 pts/0 S+ 14:56 0:00 grep --color=auto sleep