1.环境中进程的前后台调用
1)前后台调用的常用命令:
jobs | 查看被打入环境后台的进程 |
---|---|
ctrl+z | 把占用终端的进程打入后台 |
fg+jobsnum | 把后台的进程调回前台 |
bg+jobsnum | 把后台暂停的进程运行起来 |
comm+& | 让命令直接运行在后台 |
测试ctrl+z:
[root@study ~]# firefox
(process:2675): GLib-CRITICAL **: g_slice_set_config: assertion `sys_page_size == 0' failed
^Z
[1]+ Stopped firefox
# ctrl+z将该进程直接打入后台(挂在后台不再运行)
我们使用jobs进行查看:
[root@study ~]# jobs
[1]+ Stopped firefox # 被打入环境后台的进程当前只有firefox
使用bg+jobsnum,在后台让firefox运行起来:
[root@study ~]# bg firefox
[1]+ firefox & # 在后台让firefox运行起来:
[root@study ~]# jobs
[1]+ Running firefox & # 已经运行起来
使用fg+jobsnum,后台的进程调回前台:
[root@study ~]# jobs
[1]+ Running firefox &
[root@study ~]# fg 1 # 这里也可以使用jobs中的后台进程数来调用
firefox
comm+& :让命令直接运行在后台
[root@study ~]# firefox &
[1] 2807
[root@study ~]# jobs
[1]+ Running firefox &
所以说两个打入后台的命令区别:
ctrl+z将该进程直接打入后台(挂在后台不再运行)
如果使用gedit &