曲径通幽论坛

标题: bg -- 使后台停止的程序恢复运行 [打印本页]

作者: beyes    时间: 2011-5-7 12:33
标题: bg -- 使后台停止的程序恢复运行
bg 命令可以使后台停止的程序恢复运行,此后该程序看起来就是以 & 运行一般,语法格式为:

bg [工作编号]

下面做一个实验:

先运行下面的命令:
root@ubuntu:/etc# grep "PS1" ./ -R > /tmp/tmp.txt
很快的按下 Ctrl + z ,接着使用 jobs 命令可以看到:
root@ubuntu:/etc# grep "PS1" ./ -R > /tmp/tmp.txt
^Z          #ctrl + z
[1]+  Stopped                 grep --color=auto "PS1" ./ -R > /tmp/tmp.txt
root@ubuntu:/etc# jobs
[1]+  Stopped                 grep --color=auto "PS1" ./ -R > /tmp/tmp.txt

这时使用 bg 命令来将这个停止的任务重新运行起来:
root@ubuntu:/etc# jobs
[1]+  Running                 grep --color=auto "PS1" ./ -R > /tmp/tmp.txt &
由此可见,它重新运行了,注意后面还有个 & 符号。




欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2