进程调度及终止的主要命令工具:
命令行 &:将命令行在后台运行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 27050root 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 test6512[root@host50 ~]# pstree -up 6512bash(6512,test)[root@host50 ~]# pkill -9 -u test[root@host50 ~]#
[root@host50 ~]# useradd test[root@host50 ~]# su - test[test@host50 ~]$ 已杀死[root@host50 ~]#
