linux bg fg jobs 进程前后台切换

Ctrl+Z
暂停前台命令的执行,将该进程放入后台,回到SHELL

jobs
查看当前在后台执行的命令,可查看命令进程号码

&
运行命令时,在命令末尾加上&可让命令在后台执行

fg N
将命令进程号码为N的命令进程放到前台执行,同%N

bg N
将命令进程号码为N的命令进程放到后台执行

[maple@linux ~]$  ping baidu.com -a >/dev/null &
[1] 12879
[maple@linux ~]$ jobs
[1]+  Running                 ping baidu.com -a > /dev/null &
[maple@linux ~]$
[maple@linux ~]$ ping google.com -a >/dev/null
#Ctrl+Z
[2]+  Stopped                 ping google.com -a > /dev/null
[maple@linux ~]$ jobs
[1]-  Running                 ping baidu.com -a > /dev/null &
[2]+  Stopped                 ping google.com -a > /dev/null
[maple@linux ~]$
[maple@linux ~]$ fg 1
ping baidu.com -a > /dev/null
#Ctrl+Z
[1]+  Stopped                 ping baidu.com -a > /dev/null
[maple@linux ~]$ jobs
[1]+  Stopped                 ping baidu.com -a > /dev/null
[2]-  Stopped                 ping google.com -a > /dev/null
[maple@linux ~]$
[maple@linux ~]$ bg 2
[2]- ping google.com -a > /dev/null &
[maple@linux ~]$ jobs
[1]+  Stopped                 ping baidu.com -a > /dev/null
[2]-  Running                 ping google.com -a > /dev/null &
[maple@linux ~]$
[maple@linux ~]$ %2
ping google.com -a > /dev/null
#Ctrl+Z
[2]+  Stopped                 ping google.com -a > /dev/null
[maple@linux ~]$ jobs
[1]-  Stopped                 ping baidu.com -a > /dev/null
[2]+  Stopped                 ping google.com -a > /dev/null
[maple@linux ~]$
[maple@linux ~]$

 

发表评论

电子邮件地址不会被公开。

ERROR: si-captcha.php plugin: GD image support not detected in PHP!

Contact your web host and ask them to enable GD image support for PHP.

ERROR: si-captcha.php plugin: imagepng function not detected in PHP!

Contact your web host and ask them to enable imagepng for PHP.