大数据全系列 教程
1869个小节阅读:467.1k
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
###3.5.1 ps
可以通过命令查看系统内进程信息
xxxxxxxxxx
ps -ef
进程查看命令
ps(process status) :将某个时间点的程序运作情况截取下来
选项和参数
常用组合
ps aux 观察系统所有的程序数据 (常用)
xxxxxxxxxx
[root@node1 ~]# ps aux
xxxxxxxxxx
[root@node1 ~]# ps au
以下为各选项的含义
基本语法
kill [选项] 进程号 :通过进程号杀死进程(只会杀死进程号对应的一个进程)
killall 进程名称 :通过进程名称杀死进程,也支持通配符(杀死对应的一个或多个进程)
选项说明
选项 | 功能 |
---|---|
-15 | 表示让进程处理完善后的事情后关闭 |
-9 | 表示强迫进程立即停止 |
xxxxxxxxxx
[root@node1 ~]# tail -f /etc/profile &
[1] 1267
[root@node1 ~]# ps aux|grep tail
root 1267 0.0 0.0 108092 616 pts/0 S 09:38 0:00 tail -f /etc/profile
root 1270 84.0 0.0 112824 976 pts/0 R+ 09:39 0:00 grep --color=auto tail
[root@node1 ~]# kill -9 1267
[root@node1 ~]# ps aux|grep tail
root 1272 0.0 0.0 112824 972 pts/0 S+ 09:39 0:00 grep --color=auto tail
[1]+ 已杀死 tail -f /etc/profile
#killall 演示
[root@node1 ~]# tail -f /etc/profile &
[2] 1277
[root@node1 ~]# tail -f /etc/passwd &
[3] 1278
[root@node1 ~]# tail -f /etc/group &
[4] 1279
[root@node1 ~]# ps aux|grep tail
root 1274 0.0 0.0 108092 616 pts/0 S 09:42 0:00 tail -f /etc/profile
root 1277 0.0 0.0 108092 616 pts/0 S 09:42 0:00 tail -f /etc/profile
root 1278 0.0 0.0 108092 616 pts/0 S 09:43 0:00 tail -f /etc/passwd
root 1279 0.0 0.0 108092 616 pts/0 S 09:43 0:00 tail -f /etc/group
root 1282 0.0 0.0 112824 976 pts/0 S+ 09:43 0:00 grep --color=auto tail
[root@node1 ~]# killall tail
-bash: killall: 未找到命令
centos7精简安装后,使用中发现没有killall命令,于是我们想到需要安装killall:
xxxxxxxxxx
[root@node1 ~]# yum install killall -y
已加载插件:fastestmirror
......
没有可用软件包 killall。
错误:无须任何处理
这是因为对应的yum源上并没有一个名字为killall的安装包,而是给我们提供了一个psmisc安装包,安装它之后killall便可以使用了,另外pstree也是这样。
xxxxxxxxxx
[root@node1 ~]# yum install psmisc -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 psmisc.x86_64.0.22.20-17.el7 将被 安装
--> 解决依赖关系完成
......
已安装:
psmisc.x86_64 0:22.20-17.el7
完毕!
[root@node1 ~]# killall tail
[1] 已终止 tail -f /etc/profile
[2] 已终止 tail -f /etc/profile
[3]- 已终止 tail -f /etc/passwd
[root@node1 ~]# ps aux|grep tail
root 1299 0.0 0.0 112824 972 pts/0 S+ 09:47 0:00 grep --color=auto tail
[4]+ 已终止 tail -f /etc/group