Home | 簡體中文 | 繁體中文 | 雜文 | 知乎專欄 | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 視頻教程 | 打賞(Donations) | About
知乎專欄多維度架構 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者”

16.5. jobs

16.5.1. &

usage: command &

			
$ grep -r 'neo' / > result &
[1] 10414
			
			

16.5.2. Ctrl + Z

			
vim

$ vim

[2]+  Stopped                 vim


mutt

$ mutt

[3]+  Stopped                 mutt
			
			

16.5.3. jobs

			
$ jobs
[1]   Running                 grep -r 'neo' / > result &
[2]-  Stopped                 vim
[3]+  Stopped                 mutt
			
			

16.5.4. fg / bg

usage: fg [job_spec]

			
$ fg 2
			
			

usage: bg [job_spec ...]

			
$ cp -r /usr/ /tmp/
Ctrl + Z
[1]+  Stopped                 cp -r /usr/ /tmp/

$ bg
[1]+ cp -r /usr/ /tmp/ &

$ fg
cp -r /usr/ /tmp/
			
			

16.5.5. nohup - run a command immune to hangups, with output to a non-tty

			
nohup command > myout.file 2>&1 &
nohup command >/dev/null 2>/dev/null &
nohup command &>/dev/null
			
			

You may using 'jobs' to display task.

and using 'fg %n' to close that.

16.5.6. wait 等待後台任務運行結束

			
neo@MacBook-Pro ~ % sleep 10 &
[1] 2967

neo@MacBook-Pro ~ % wait
[1]  + 2967 done       sleep 10			
			
			

wait 將一隻停留,等待 sleep 10 運行完畢。