[CentOS 7系列]作业控制

前端之家收集整理的这篇文章主要介绍了[CentOS 7系列]作业控制前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、jobs

[root@server01~]#top
top-06:39:07up8:24,3users,loadaverage:0.01,0.04,0.05
Tasks:87total,1running,84sleeping,2stopped,0zombie
%cpu(s):0.5us,0.4sy,0.0ni,99.0id,0.1wa,0.0hi,0.0si,0.0st
KiBMem:1008392total,157936free,132356used,718100buff/cache
KiBSwap:2097148total,2097148free,0used.660208availMem

PIDUSERPRNIVIRTRESSHRS%cpu%MEMTIME+COMMAND
30125root20015757220761504R6.20.20:00.01top
1root2004552858123672S0.00.60:02.34systemd
2root200000S0.00.00:00.01kthreadd
3root200000S0.00.00:04.36ksoftirqd/0
4root200000D0.00.00:38.92kworker/0:0
7rootrt0000S0.00.00:00.00migration/0
8root200000S0.00.00:00.00rcu_bh
9root200000S0.00.00:01.27rcu_sched
10rootrt0000S0.00.00:02.68watchdog/0
12root0-20000S0.00.00:00.00khelper
13root200000S0.00.00:00.00kdevtmpfs
14root0-20000S0.00.00:00.00netns
15root200000S0.00.00:00.01khungtaskd
16root0-20000S0.00.00:00.00writeback
17root0-20000S0.00.00:00.00kintegrityd
18root0-20000S0.00.00:00.00bioset
19root0-20000S0.00.00:00.00kblockd
[1]+已停止top##ctrl+z暂停一个任务
[root@server01~]#cat/etc/passwd|wc-l&##管道符表示后面的命令作用于前面命令的结果
[2]30138##“&”表示放在后台运行
[root@server01~]#21
jobs##jobs命令用于查看后台的任务
[1]+已停止top
[2]-完成cat/etc/passwd|wc-l


2、fg

[root@server01~]#jobs
[1]-已停止top
[2]+已停止manfdisk
[root@server01~]#fg1##将任务调度到前台运行
top-06:58:25up8:43,loadaverage:0.00,0.01,0.05
Tasks:102total,3running,82sleeping,17stopped,0zombie
%cpu(s):0.0us,0.2sy,99.8id,0.0wa,153464free,136164used,718764buff/cache
KiBSwap:2097148total,0used.656136availMem

PIDUSERPRNIVIRTRESSHRS%cpu%MEMTIME+COMMAND
4root200000R0.20.00:40.85kworker/0:0
30083root20014302055564252S0.10.60:00.93sshd
9root200000S0.00.00:01.34rcu_sched
287root200000S0.00.00:08.18xfsaild/sda3
502root200327432269126556S0.02.70:04.39firewalld
30087root20011550821681764R0.00.20:00.21bash
1root2004552858123672S0.00.60:02.35systemd
10rootrt0000S0.00.00:02.71watchdog/0
801root200553152185205816S0.01.80:07.17tuned
20876root200000S0.00.00:00.41kworker/u12+
2root200000S0.00.00:00.01kthreadd
3root200000S0.00.00:04.39ksoftirqd/0
7rootrt0000S0.00.00:00.00migration/0
8root200000S0.00.00:00.00rcu_bh
12root0-20000S0.00.00:00.00khelper
13root200000S0.00.00:00.00kdevtmpfs
14root0-20000S0.00.00:00.00netns
##ctrl+c结束一个任务
[root@server01~]#jobs
[2]+已停止manfdisk


3、bg

[root@server01~]#jobs
[2]-已停止manfdisk
[3]+已停止ping-c100114.114.114.114
[root@server01~]#bg3##放在后台继续运行
[3]+ping-c100114.114.114.114&
[root@server01~]#64bytesfrom114.114.114.114:icmp_seq=84ttl=58time=7.58ms
64bytesfrom114.114.114.114:icmp_seq=85ttl=58time=10.2ms
64bytesfrom114.114.114.114:icmp_seq=86ttl=58time=5.25ms
job64bytesfrom114.114.114.114:icmp_seq=87ttl=58time=11.5ms
s
[2]+已停止manfdisk
[3]-运行中ping-c100114.114.114.114&

如果正在运行一个进程,而且希望在退出帐户时该进程还不会结束,那么可以使用nohup命令(nohup command &)。该命令可以在用户退出帐户之后继续运行相应的进程。

原文链接:https://www.f2er.com/centos/376985.html

猜你在找的CentOS相关文章