进程调度及终止的主要命令工具

进程调度及终止的主要命令工具:

  • 命令行 &:将命令行在后台运行
  • Ctrl + z 组合键:挂起当前进程(暂停并转入后台)
  • jobs:列出当前用户当前终端的后台任务
  • bg 编号:启动指定编号的后台任务
  • fg 编号:将指定编号的后台任务调入前台运行
  • kill [-9] PID...:杀死指定PID值的进程
  • kill [-9] %n:杀死第n个后台任务
  • killall [-9] 进程名...:杀死指定名称的所有进程
  • pkill:根据指定的名称或条件杀死进程

[root@host50 mongodbdir]# ps aux | grep mongo
root      1742  0.3  8.4 1047756 85684 ?       Sl   11:45   1:35 mongod -f /usr/local/mongodb/etc/mongodb.conf
root      4577  0.0  2.5 780048 26212 pts/0    Sl+  16:24   0:00 mongo --host 192.168.4.50 --port 27050

root      6432  0.0  0.0 112676   980 pts/1    S+   19:21   0:00 grep --color=auto mongo

[root@host50 mongodbdir]# kill -9 1742
[root@host50 mongodbdir]# kill -9 4577
[root@host50 mongodbdir]# kill -9 6432
-bash: kill: (6432) - 没有那个进程

> 已杀死
[root@host50 ~]# 


[root@host50 ~]# jobs -l
[root@host50 ~]# killall -9 vim

[root@host50 ~]# jobs -l
[1]   6457 停止 (tty 输出)     vim test.txt
[2]   6458 停止 (tty 输出)     vim test1.txt
[3]   6459 停止 (tty 输出)     vim test2.txt
[4]-  6468 停止 (tty 输出)     vim test2.txt
[5]+  6469 停止 (tty 输出)     vim test2.txt
[root@host50 ~]# jobs -l
[1]   6457 已杀死               vim test.txt
[2]   6458 已杀死               vim test1.txt
[3]   6459 已杀死               vim test2.txt
[4]-  6468 已杀死               vim test2.txt
[5]+  6469 已杀死               vim test2.txt

[root@host50 ~]# 

[root@host50 ~]# jobs -l    //确认进程是否还存在

管理员管理用户

[root@host50 ~]# pgrep -u test
6512
[root@host50 ~]# pstree -up 6512
bash(6512,test)
[root@host50 ~]# pkill -9 -u test
[root@host50 ~]# 

[root@host50 ~]# useradd test
[root@host50 ~]# su - test
[test@host50 ~]$ 已杀死
[root@host50 ~]# 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乐于技术分享

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值