进程管理

8266 字
41 分钟
进程管理
进程管理

进程管理#



01.进程概述#

名字含义
程序安装包,程序代码,app,存放在磁盘上面,df -h 查看的就是磁盘
进程 ⭐运行起来的程序,命令,服务(远程连接服务,网络服务)都可以称作进程,运行在内存中,free -h 查看的就是内存
守护进程一直运行的进程,也可以叫做服务
  • 内存越大,你同时运行的进程就越多!

进程的创建流程:

创建 fork

执行任务 exec

退出 exit

正常流程

Process主进程

皇帝·最大

child process 子进程

大臣·和珅·纪晓岚

child process

百姓

process主进程

创建 fork

执行任务 exec

退出 exit

正常流程

Process主进程

皇帝·最大

child process 子进程

大臣·和珅·纪晓岚

child process

百姓

process主进程

  • 主进程最大,皇帝只有一个
  • 有的进程可以直接干活(主进程自己就干完了)
  • 有的需要再次进行任务的分发(fork出子进程去干)

pstree#

以树形结构显示进程之间的关系

下载#

yum install -y psmisc

Terminal window
[root@oldboy ~]# yum install -y psmisc
Installed:
psmisc-23.3-2.ky10.x86_64
Complete!

使用#

Terminal window
[root@oldboy ~]# pstree
systemd-+-NetworkManager---2*[{NetworkManager}]
|-abrtd---2*[{abrtd}]
|-agetty
|-atd
|-chronyd
|-crond
|-dbus-daemon
|-gssproxy---5*[{gssproxy}]
|-kylin_kms_daemo---{kylin_kms_daemo}
|-kylin_sock_serv
|-lsmd
|-lvmdbusd---3*[{lvmdbusd}]
|-mdadm
|-polkitd---5*[{polkitd}]
|-rngd---{rngd}
|-rsyslogd---2*[{rsyslogd}]
|-smartd
|-sshd---sshd---sshd---bash---pstree
|-sssd-+-sssd_be
| |-sssd_nss
| `-sssd_pam
|-systemd---(sd-pam)
|-systemd-journal
|-systemd-logind
|-systemd-udevd
`-tuned---3*[{tuned}]
[root@oldboy ~]#
# 所有的进程都由systemd这个主进程管理着
pstree -p#

显示进程号

Terminal window
[root@oldboy ~]# pstree -p
systemd(1)-+-NetworkManager(765)-+-{NetworkManager}(809)
| `-{NetworkManager}(813)
|-abrtd(750)-+-{abrtd}(817)
| `-{abrtd}(819)
|-agetty(1070)
|-atd(1062)
|-chronyd(738)
|-crond(1063)
|-dbus-daemon(723)
|-gssproxy(1049)-+-{gssproxy}(1052)
| |-{gssproxy}(1053)
| |-{gssproxy}(1054)
| |-{gssproxy}(1055)
| `-{gssproxy}(1056)
# 主进程id为1

⚠️僵尸进程:#

创建 fork

执行任务 exec

退出 exit

回收

没有回收,释放资源

Process主进程

皇帝

child process 子进程

child process

百姓

父进程回收资源了吗

正常退出

zombie 僵尸进程

挂了,人还在

创建 fork

执行任务 exec

退出 exit

回收

没有回收,释放资源

Process主进程

皇帝

child process 子进程

child process

百姓

父进程回收资源了吗

正常退出

zombie 僵尸进程

挂了,人还在

子进程比父进程先结束,而父进程没有回收子进程,也没有释放子进程占用的资源,此时子进程变为僵尸进程

  • 僵尸进程: 挂了,不干活,但是依旧占用着这些资源

如何查看#

top#
Terminal window
[root@oldboy ~]# top
top - 16:26:26 up 11 min, 1 user, load average: 0.01, 0.02, 0.02
Tasks: 137 total, 1 running, 136 sleeping, 0 stopped, 0 zombie
# 第2行最后的 zombie 就是僵尸进程的个数
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 932.2 total, 404.5 free, 199.2 used, 328.4 buff/cache
MiB Swap: 2088.0 total, 2088.0 free, 0.0 used. 573.2 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1 root 20 0 103552 11620 8932 S 0.0 1.2 0:01.72 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
6 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 kworker/0:0H-event:
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.04 kworker/0:1H-event:
9 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
ps aux | grep Z#

Z就是僵尸进程的标志!

Terminal window
[root@oldboy-lnb-king-v3 ~]# ps aux |grep Z
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 4232 0.0 0.0 0 0 pts/0 Z+ 09:57 0:00 [zombie.bin] <defunct>
# 进程ID 4232 STAT是Z+ 僵尸进程 [zombie.bin] <defunct>
root 4299 0.0 0.0 112824 960 pts/1 R+ 09:58 0:00 grep --color=auto Z
# 1)先抓到僵尸的 PID
root@Docker:~# ps aux | awk '$8~/Z/'
USER PID ... STAT COMMAND
jiuzhao 2001 ... Z [myproc] <defunct>

如何解决?#

①找出僵尸进程的上级进程(父进程),结束掉即可

Terminal window
1)先用pstree -p找到僵尸进程的父进程
[root@oldboy-lnb-king-v3 ~]# pstree -p | grep 4232
|-sshd(1553)---sshd(1344)---bash(1348)---zombine.bin(4231)---zombine.bin(4232)
# 父进程是4231
`不要用这种方式找`
# 用 pstree -ps 画它的父链
root@Docker:~# pstree -ps 2001
systemd(1)───sshd(1000)───bash(1001)───myproc(2000)───myproc(2001)
↑ 父进程 ↑ 僵尸自己
2)直接杀4232,根本杀不掉
[root@oldboy-lnb-king-v3 ~]# kill 4232
[root@oldboy-lnb-king-v3 ~]# kill -9 4232
[root@oldboy-lnb-king-v3 ~]# kill -9 4232
# 没有办法直接杀死4232
'僵尸进程已经挂了,kill对它无效'
3)干掉父进程4231
[root@oldboy-lnb-king-v3 ~]# kill 4231
# 父进程一死,僵尸进程4232被系统接管并回收
# 回收之后,僵尸进程就直接消失了

②如果上级进程为主进程(pid为1的进程,皇帝进程),则需要重新启动Linux系统.

Terminal window
[root@oldboy ~]# ps -ef | head -3
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:14 ? 00:00:01 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root 2 0 0 16:14 ? 00:00:00 [kthreadd]
# PID为1的就是主进程,皇帝进程
# 皇帝进程产生的僵尸进程,只能重启Linux系统来清理

孤儿进程:#

创建 fork

执行任务 exec

父进程没了

由系统直接接管

Process主进程

父进程

child process 子进程

child process nginx

百姓

挂了

创建 fork

执行任务 exec

父进程没了

由系统直接接管

Process主进程

父进程

child process 子进程

child process nginx

百姓

挂了

父进程执行完毕,或者异常退出后,子进程仍然运行着.

  • 那么这个子进程就变成了孤儿进程.

  • 孤儿进程会被系统直接接管.

  • 这个孤儿进程也还能用.


02.进程监控命令#

Linux中必会的查询进程信息的命令

监控命令类型含义
ps静态ps查看当前瞬间进程状态,一般用于临时检查或取值
top动态top动态,交互,整体查看系统状态,负载,僵尸进程,cpu,内存,类似于windows任务管理器

①ps命令#

ps -ef#

Terminal window
[root@oldboy ~]# ps -ef | head -4
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 16:14 ? 00:00:02 /usr/lib/systemd/systemd

主进程PID=1只需记住systemd这个进程名字就够用了.

  • UID: 进程所属用户

  • PID: 进程id号,大部分都是随机的.

Terminal window
1)重启前查看sshd的PID
[root@oldboy-lnb-king-v3 ~]# ps -ef |grep '/usr/sbin/sshd'
root 1553 1 0 12月06 ? 00:00:00 /usr/sbin/sshd -D
root 6018 1348 0 10:33 pts/0 00:00:00 grep --color=auto /usr/sbin/sshd
2)重启sshd服务
[root@oldboy-lnb-king-v3 ~]# systemctl restart sshd
3)重启后再看,PID不同了
[root@oldboy-lnb-king-v3 ~]# ps -ef |grep '/usr/sbin/sshd'
root 6035 1 1 10:33 ? 00:00:00 /usr/sbin/sshd -D
root 6038 1348 0 10:33 pts/0 00:00:00 grep --color=auto /usr/sbin/sshd
# 1553和6035不同,重启后PID变了
# 两次都是/usr/sbin/sshd,是同一个服务
  • PPID: 父进程的id号

    • pstree -p查看详细关系
Terminal window
1)用pstree -p看父子关系
[root@oldboy ~]# pstree -p | grep sleep
|-screen(2014)---bash(2015)---sleep(2085)
# 父进程
2)ps -ef对照着看PPID列
[root@oldboy ~]# ps -ef | grep sleep
root 2085 2015 0 10:36 pts/1 00:00:00 sleep 999
# 进程ID:2085 PPID:2015
# sleep的PID是2085,它父进程bash的PID是2015
  • CMD: 进程名字

ps aux#

虽然 ps -ef 与 ps aux 命令都能查看进程运行情况,但两者之间还是有一些细致区别.

输出示例:

Terminal window
[root@oldboyedu ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
#进程属于用户 子进程id cpu/mem百分比 占用虚拟内存 占用物理内存 终端 进程状态 进程启动时间 进程占用CPU时间 进程名称
root 1 0.0 0.4 125776 4184 ? Ss Apr07 0:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root 2 0.0 0.0 0 0 ? S Apr07 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< Apr07 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S Apr07 0:00 [ksoftirqd/0]
root 7 0.0 0.0 0 0 ? S Apr07 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S Apr07 0:00 [rcu_bh]
root 2440 0.0 0.2 116200 2604 tty1 Ss+ 04:13 0:00 -bash
root 3047 0.0 0.0 0 0 ? S 07:37 0:00 [kworker/u256:1]
root 3054 0.0 0.6 161536 6088 ? Ss 07:40 0:00 sshd: root@pts/1
root 3056 0.0 0.2 116212 2652 pts/1 Ss+ 07:40 0:00 -bash
mysql 3269 0.0 0.1 113416 1604 ? Ss 07:47 0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
mysql 3434 0.0 8.7 968916 86980 ? Sl 07:47 0:01 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql
root 3491 0.0 0.0 110412 956 pts/0 S+ 07:50 0:00 less
root 3506 0.0 0.0 0 0 ? S 08:17 0:00 [kworker/0:1]
root 4018 4.5 0.5 149328 5020 pts/2 T 09:06 0:00 vim oldboy.txt
root 2763 20.3 0.1 123848 1652 pts/1 D+ 15:09 0:06 tar zcf /tmp/etc.tar.gz /etc/ /usr/
# VSZ/RSS 单位都是KB
# TTY列是 ? 表示该进程不占用终端
进程状态:#
  • 进程状态: 进程运行中,僵尸进程,正在进行io的进程,前台或后台运行进程
  • 进程状态: 基本状态+附加组成
STAT基本状态描述STAT状态+符号描述
R进程运行s父进程,管理进程
S可中断睡眠<高优先级
T进程被暂停N低优先级
D不可中断睡眠+进程运行在前台
Z僵尸进程l(小写)进程是多线程的
Terminal window
# I Idle(空闲)
# 意味着该进程(通常是内核线程)正在等待事件发生
# 它不会消耗CPU时间,但处于"准备响应"的状态
  • 进程名带 [ ] 都是些Linux内核进程
Terminal window
[root@oldboy ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.2 0.5 103548 11520 ? Ss 10:23 0:01 /usr/lib/systemd/systemd --switched-root
root 2 0.0 0.0 0 0 ? S 10:23 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 10:23 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 10:23 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 10:23 0:00 [kworker/0:0H-events_highpri]
root 7 0.0 0.0 0 0 ? R 10:23 0:00 [kworker/u256:0-events_unbound]
root 8 0.0 0.0 0 0 ? I< 10:23 0:00 [kworker/0:1H-events_highpri]
root 9 0.0 0.0 0 0 ? I< 10:23 0:00 [mm_percpu_wq]
root 10 0.0 0.0 0 0 ? S 10:23 0:00 [ksoftirqd/0]
root 11 0.0 0.0 0 0 ? I 10:23 0:00 [rcu_sched]
root 12 0.0 0.0 0 0 ? I 10:23 0:00 [rcu_bh]
root 13 0.0 0.0 0 0 ? S 10:23 0:00 [migration/0]
root 14 0.0 0.0 0 0 ? S 10:23 0:00 [cpuhp/0]
# 进程名带括号[]的都是内核进程
  • S(可中断睡眠)和Ss就是top中的sleeping进程!
Terminal window
top - 19:28:12 up 3:13, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 141 total, 1 running, 140 sleeping, 0 stopped, 0 zombie
# sleeping睡眠
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.3 hi, 0.0 si, 0.0 st
MiB Mem : 932.2 total, 300.3 free, 223.1 used, 408.7 buff/cache
MiB Swap: 2088.0 total, 2088.0 free, 0.0 used. 537.4 avail Mem
# top第2行的sleeping,就是S或者Ss状态的进程
  • T(被挂起的进程)就是top中的stopped进程!
Terminal window
top - 21:01:29 up 4:46, 2 users, load average: 0.00, 0.00, 0.00
Tasks: 141 total, 2 running, 139 sleeping, 0 stopped, 0 zombie
# stopped被暂停
%Cpu(s): 0.0 us, 6.2 sy, 0.0 ni, 93.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 932.2 total, 300.0 free, 223.3 used, 408.8 buff/cache
MiB Swap: 2088.0 total, 2088.0 free, 0.0 used. 537.2 avail Mem
# top第2行的stopped,就是T 挂起进程,被暂停
  • S+前台运行
Terminal window
1)第一个窗口前台运行sleep 10
[root@oldboy ~]# sleep 10
2)第二个窗口查看
[root@oldboy ~]# ps aux | grep sleep
root 5370 0.0 0.0 212380 808 pts/1 S+ 20:31 0:00 sleep 10
root 5372 0.0 0.0 213140 876 pts/2 R+ 20:31 0:00 grep --color=auto sleep
# S+ 前台运行
  • 多线程得需要软件支持!
Terminal window
# 使用tar打包文件时,另一个窗口可以通过ps aux查看状态,由S+,R+变为D+
[root@lzy ~]# ps axu|grep tar|grep -v grep
root 14289 2.6 0.1 124268 1888 pts/2 S+ 10:56 0:01 tar zcf etc.tar.gz /etc/ /usr/ /var
[root@lzy ~]# ps axu|grep tar|grep -v grep
root 14289 2.7 0.2 124380 2240 pts/2 R+ 10:56 0:01 tar zcf etc.tar.gz /etc/ /usr/ /var
[root@lzy ~]# ps axu|grep tar|grep -v grep
root 14289 2.9 0.2 124916 2724 pts/2 D+ 10:56 0:01 tar zcf etc.tar.gz /etc/ /usr/ /var
# S+ -> R+ -> D+ 打包挤压大量IO时,会看到D 不可中断睡眠

常见的进程状态:

  1. R+ 前台运行中的进程

  2. Ss 可中断的管理进程

  3. S< 可中断的高级进程

  4. Ssl 可中断的多线程的管理进程

  5. D 不可中断的IO进程

  6. Z 僵尸进程

两个ps命令的区别:

  1. 在 ps -ef 中,查看所有进程及其详细信息,并显示父进程 ID.

  2. 在 ps aux 中, 包含了%CPU和%MEM列以及进程的状态信息,

  3. 重点在资源使用情况,像CPU%和内存%的占用率等等.

ps aux 没有 -

🧣pgrep#

Terminal window
# 按条件查找进程
1)列出包含sshd的PID和进程名
[root@Rocky10 home]# pgrep -l sshd
1405 sshd
1452 sshd-session
1913 sshd-session
2)列出root用户的所有进程
'root用户的进程太多了,不建议查看root用户的!'
[root@Rocky10 home]# pgrep -u root
1
2
3)列出指定终端的进程
root@Rocky10:~# who
root pts/0 2026-03-06 09:12 (10.0.0.1)
root seat0 2026-03-06 14:16 (login screen)
root tty2 2026-03-06 14:16 (tty2)
[root@Rocky10 home]# pgrep -t pts/0
1919
# 这个pts是伪终端,也就是Xshell连接的那个!
'你一看这个终端登录了,之后通过查看登录终端的进程,可以指定杀它'
# 按的是终端查看,而不是用户
root@Rocky10:~# kill -9 1919
root@Rocky10:~# who
root seat0 2026-03-06 14:16 (login screen)
root tty2 2026-03-06 14:16 (tty2)
[root@Rocky10 home]# Connection closing...Socket close.
# 我们回到Xshell,连接中断!

②top命令#

  • 它是个交互式的命令

    • 下面有它的快捷键
  • 可以非交互式

输出完之后,自动退出

  • top -bn1

    • -b 非交互式模式
    • -n 输出的次数为1次
  • 可以展示系统负载,进程,CPU,内存…

  • 类似于Windows的任务管理器

什么是中断?

中断就是终止当前在做的事情 去执行另一段程序

会保留现场,执行的那段程序做完之后会再回来执行刚来尚未完成的部分

CPU收到中断信号

转到

执行结束

正在运行的程序

中断

CPU暂停当前程序

执行中断服务程序

中断返回

返回继续执行原程序

CPU收到中断信号

转到

执行结束

正在运行的程序

中断

CPU暂停当前程序

执行中断服务程序

中断返回

返回继续执行原程序

us和sy#

Terminal window
# us用户态: 用户执行命令占用CPU百分比
yum -y install wget # 比如用户敲的安装命令,消耗的就是用户态
# sy内核态: 硬件执行占用CPU百分比
# 用户态: 由服务通知CPU,没有办法直接调用硬件
# 内核态: CPU调用我们的内核驱动,调用磁盘读取内容

快捷键#

Terminal window
# 基础必会用法
q # 退出
空格 # 默认3秒刷新1次,按空格立刻刷新
P # 默认按照CPU使用率排序(大写,默认是P)
M # 按照内存使用率排序
# 进阶用法
# top输入z进入颜色模式,再按x标记出当前是按照哪列排序
shift + > # 向右
shift + < # 向左
  • 按完z后,紧跟着的就是x

  • shift + > 向右,shift + < 向左

Terminal window
top - 09:30:00 up 0 min, 1 user, load average: 0.44, 0.10, 0.03
Tasks: 213 total, 2 running, 211 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.7 sy, 0.0 ni, 99.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 7989844 total, 6087476 free, 1114664 used, 787704 buff/cache
KiB Swap: 3145724 total, 3145724 free, 0 used. 6613912 avail Mem
# 默认的%Cpu(s)是所有CPU核心的平均值
  • 1可以查看多个CPU核心数
Terminal window
# 按下数字1之后
%Cpu0 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu1 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu2 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu3 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
# 每个CPU核心单独一行,这台机器是4个核心

htop#

需要提前配置好epel源,然后安装即可

yum -y install htop

Terminal window
[root@oldboy ~]# yum -y install htop
Last metadata expiration check: 0:48:24 ago on Wed 24 Dec 2025 01:33:45 PM CST.
Dependencies resolved.
=================================================================================================
Package Architecture Version Repository
=================================================================================================
Installing:
htop x86_64 3.0.5-4.ky10 ks10-adv-os
Transaction Summary
=================================================================================================
Install 1 Package

  • 这个功能非常齐全.

取僵尸进程个数#

利用到非交互模式

未来想要取top命令的结果,指标,需要让top命令运行在非交互模式

Terminal window
1)先看第2行
[root@oldboy ~]# top -bn1 | awk 'NR==2'
Tasks: 137 total, 2 running, 135 sleeping, 0 stopped, 0 zombie
2)配合awk取出僵尸进程的个数
[root@oldboy ~]# top -bn1 | awk 'NR==2{print $NF"僵尸进程的个数为"$(NF-1)}'
zombie僵尸进程的个数为0
# $NF 取最后一列 zombie
# $(NF-1) 取倒数第二列的0
  • top -bn1

    • -b 非交互式模式

    • -n 输出的次数为1次

  • 这里利用 ” “双引号替代 ,逗号 进行分隔.

  • NR==2 取第二行

③lsof#

用于列出当前系统中被进程打开的文件

详细内容请看磁盘相关案例

🧣负载高?#

  • 负载高和系统的可运行状态(R,S)和不可中断(D)(读写IO)的平均进程数有关.

    • 系统的繁忙程度

    • 越接近CPU核心数,系统的负载越高.

✅️ 排查流程

  • (1)通过监控软件发现系统负载高(w,lscpu查看)
  • (2)判断是cpu还是io导致的负载高
    • cpu高: top中的 us(user 用户占用cpu), sy(system 系统占用cpu)
    • io高: top中的 wa(iowait), 磁盘io导致的负载高,去找读写进程
  • (3)定位进程
    • 如果是cpu导致的,排查出哪个进程导致的,ps aux过滤出占用cpu较高的进程
    • 如果是io导致的,排查出哪个进程导致的,通过 iotop -o 命令排查(显示正在读写的进程)
  • (4)未完待续.(具体分析这个进程有啥问题,第2阶段再说)

%user %sys 高 cpu导致

%wait 高 io导致

进程占用大量io

通过监控得知系统负载高

排查1 简单查看

w/top/uptime 查看系统负载

lscpu 负载达到CPU核心总数60-70%

排查2 什么导致

top命令查看

排查3 ps aux/htop/top

定位进程与服务

排查3 iotop

排查系统哪些进程进行大量读写

%user %sys 高 cpu导致

%wait 高 io导致

进程占用大量io

通过监控得知系统负载高

排查1 简单查看

w/top/uptime 查看系统负载

lscpu 负载达到CPU核心总数60-70%

排查2 什么导致

top命令查看

排查3 ps aux/htop/top

定位进程与服务

排查3 iotop

排查系统哪些进程进行大量读写

  • 如果是CPU导致,是us还是sy,上面有详细的区分

  • IO高用iotop -o进一步排查

iotop -o#

显示正在读写的进程

yum -y install iotop

Terminal window
[root@oldboy ~]# iotop -o
Total DISK READ : 0.00 B/s | Total DISK WRITE : 0.00 B/s
Actual DISK READ: 0.00 B/s | Actual DISK WRITE: 0.00 B/s
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
2697 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.04 % [kworker/0:0-events]
# -o 只显示正在读写的进程

03.ps常见操作:#

①过滤出进程信息:#

Terminal window
1)过滤出crond进程
[root@oldboy ~]# ps -ef | grep crond
root 1058 1 0 10:23 ? 00:00:00 /usr/sbin/crond -n
root 1346 1294 0 10:24 pts/0 00:00:00 grep --color=auto crond
# 这个是grep过滤自己的进程
[root@oldboy ~]# ps aux | grep crond
root 1058 0.0 0.1 222940 3084 ? Ss 10:23 0:00 /usr/sbin/crond -n
root 1348 0.0 0.0 213140 820 pts/0 R+ 10:24 0:00 grep --color=auto crond
# 过滤结果里混着grep自己的进程,可以排除掉
Terminal window
2)-v 排除自己的grep进程
[root@oldboy ~]# ps -ef | grep crond | grep -v grep
root 1058 1 0 10:23 ? 00:00:00 /usr/sbin/crond -n
# 只剩下crond
3)并统计进程的数量
[root@oldboy ~]# ps -ef | grep crond | grep -v grep | wc -l
1
Terminal window
4)尽可能的详细,排除掉没有用的信息
[root@oldboy ~]# ps aux | grep sshd
root 1043 0.0 0.3 21840 6764 ? Ss 10:23 0:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root 1266 0.0 0.4 239860 9136 ? Ss 10:23 0:00 sshd: root [priv]
root 1289 0.0 0.3 244068 6524 ? S 10:23 0:00 sshd: root@pts/0
root 1435 0.0 0.0 213140 884 pts/0 R+ 10:39 0:00 grep --color=auto sshd
# 主要是这个进程信息,sshd服务的主进程
[root@oldboy ~]# ps aux | grep '/usr/sbin/sshd'
root 1043 0.0 0.3 21840 6764 ? Ss 10:23 0:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root 1441 0.0 0.0 213272 876 pts/0 S+ 10:42 0:00 grep --color=auto /usr/sbin/sshd
# 想过滤得更加精确,就带上完整的命令路径
  • 尽可能的详细,排除掉没有用的信息!

②按照树形结构查看进程信息#

Terminal window
# 一般用于查看进程间关系
pstree
pstree -p # 显示树形结构并输出pid
ps auxf # 也可以展示部分所属关系,没有pstree直观
Terminal window
1)pstree -p
|-sshd(1043)---sshd(1266)---sshd(1289)---bash(1294)---pstree(1766)
|-sssd(750)-+-sssd_be(831)
| |-sssd_nss(847)
| `-sssd_pam(848)
2)ps auxf
[root@oldboy ~]# ps auxf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1043 0.0 0.3 21840 6764 ? Ss 10:23 0:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
root 1266 0.0 0.4 239860 9136 ? Ss 10:23 0:00 \_ sshd: root [priv]
root 1289 0.0 0.3 244068 6524 ? S 10:23 0:00 \_ sshd: root@pts/0
root 1294 0.0 0.2 223700 5240 pts/0 Ss 10:23 0:00 \_ -bash
root 1763 0.0 0.1 225212 3816 pts/0 R+ 12:15 0:00 \_ ps auxf
# 用 \_ 缩进展示父子关系

③显示某几列#

Terminal window
# 根据要求取出ps命令结果中部分内容
# 通过awk取列
ps aux | awk '{print $1}'
ps aux | awk '{print $2}'
ps aux | awk '{print $3}'
ps aux | awk '{print $1,$3}' # 第1列和第3列
# ps命令的选项,输出指定的内容
ps axo user,%cpu,stat
ps axo user,%cpu,stat,cmd
'ps aux的u换成o,注意顺序'
Terminal window
# awk的弊端
[root@oldboy ~]# ps aux | awk '{print $NF}'
-P
-D
-f
-n
linux
[priv]
--user
(sd-pam)
root@pts/0
-bash
[kworker/0:1-ata_sff]
[kworker/0:0-ata_sff]
[kworker/0:2-events]
/usr/bin/kylin_kms_daemon
aux
# awk默认按空格分隔取列
# ⚠️ CMD列里带空格的命令,只会取到最后一段,会取到后面的一些选项
'这就是awk的弊端'
Terminal window
[root@oldboy ~]# ps axo user,cmd
USER CMD
root /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root [kthreadd]
root [rcu_gp]
# 取某几列,逗号隔开

不显示标题#

Terminal window
# awk法 排除第1行,从第2行开始
ps aux |awk 'NR>1{print $1,$3}'
# awk '{print 列}'
# awk '条件{print 列}'
# awk 'NR>=1{print 列}'
# NR>1 行号大于1
# NR>=2 行号大于等于2
# ps不输出每一列的标题
ps --no-heading axo user,%cpu,stat
Terminal window
[root@oldboy ~]# ps axo user,cmd --no-heading
root /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root [kthreadd]
root [rcu_gp]
# 没有标题了

④取出某个进程的指定列#

Terminal window
1)先过滤出cron进程
[root@oldboy ~]# ps aux | grep 'cron'
root 1058 0.0 0.1 222940 3108 ? Ss 10:23 0:00 /usr/sbin/crond -n
root 1860 0.0 0.0 213140 880 pts/0 R+ 12:44 0:00 grep --color=auto cron
2)排除本身grep这一行
[root@oldboy ~]# ps aux | grep 'cron' | grep -v 'grep'
root 1058 0.0 0.1 222940 3108 ? Ss 10:23 0:00 /usr/sbin/crond -n
3)取出某几列
[root@oldboy ~]# ps aux | grep 'cron' | grep -v 'grep' | awk '{print $1,$2,$3}'
root 1058 0.0

⑤取出所有进程中内存使用率最高的前5#

使用sort进行排序

Terminal window
[root@oldboy ~]# ps aux --no-heading | sort -rnk4 | head -5
root 847 0.0 1.7 264364 35780 ? S 10:23 0:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root 1044 0.0 1.3 480108 27232 ? Ssl 10:23 0:01 /usr/bin/python3 -Es /usr/sbin/tuned -l -P
polkitd 745 0.0 1.0 2588112 20828 ? Ssl 10:23 0:00 /usr/lib/polkit-1/polkitd --no-debug
root 781 0.0 0.9 472200 19740 ? Ssl 10:23 0:00 /usr/sbin/NetworkManager --no-daemon
root 831 0.0 0.6 251444 12328 ? S 10:23 0:00 /usr/libexec/sssd/sssd_be --domain implicit_files --uid 0 --gid 0 --logger=files
# 第4列%MEM按数字倒序,取前5名

ps aux --no-heading | sort -rnk4 | head -5

  • k4 按第四列内存使用率排序

  • rn 按数字,倒序排序

  • —no-heading 不显示标题

  • head -5 取前五名

Terminal window
[root@oldboy ~]# ps aux --no-heading --sort=-%mem | head -5
root 847 0.0 1.7 264364 35780 ? S 10:23 0:00 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --logger=files
root 1044 0.0 1.3 480108 27232 ? Ssl 10:23 0:01 /usr/bin/python3 -Es /usr/sbin/tuned -l -P
polkitd 745 0.0 1.0 2588112 20828 ? Ssl 10:23 0:00 /usr/lib/polkit-1/polkitd --no-debug
root 781 0.0 0.9 472200 19740 ? Ssl 10:23 0:00 /usr/sbin/NetworkManager --no-daemon
root 620 0.0 0.6 30720 12408 ? Ss 10:23 0:00 /usr/lib/systemd/systemd-journald
# --sort 是长选项
# 指标前面加 - 减号表示降序排

ps aux --no-heading --sort=-%mem | head -5

  • —sort 默认是升序排

    • 指标前面加 - 减号表示降序排序

04.后台管理#

概述#

前台

前台运行,当前正在用的软件或进程.

  • ps aux进程状态中,带有+,表示前台运行的进程.

  • Xshell远程连接,敲的命令都是前台命令.

Terminal window
1)第一个窗口,前台运行sleep
[root@oldboy ~]# sleep 999
# 前台运行,可中断睡眠
2)第二个窗口查看
[root@oldboy ~]# ps aux | grep 'sleep' | grep -v 'grep'
root 2615 0.0 0.0 212380 748 pts/0 S+ 14:59 0:00 sleep 999
# S+ 第二个窗口有这个进程
3)断开第一个窗口的连接
# Xshell弹出提示: 你已连接到10.0.0.200:22,你要断开并关闭这个标签吗?
4)断开后,第二个窗口再过滤
[root@oldboy ~]# ps aux | grep 'sleep' | grep -v 'grep'
[root@oldboy ~]#
# 过滤不到进程了
⚠️ 断开连接后,前台命令结束,进程结束
  • 所以一些临时的操作,就给前台了.

后台

后台运行,“默默无闻”的运行.

  • 大部分软件和进程都是在后台运行.

  • ps aux进程状态中,大部分都不带+,后台运行

  • 即使Xshell连接断开,也会持续运行.

root@rocky10:~# vim 1.sh
root@rocky10:~# cat 1.sh
#! /bin/bash
while :
do
date >> /root/1.txt
sleep 1
done
root@rocky10:~# > /root/1.txt
# 运行./1.sh,然后关闭终端,然后cat /root/1.txt,验证脚本停止运行,没有新的写入
# 运行./1.sh &,然后关闭终端,然后cat /root/1.txt,验证脚本停止运行,没有新的写入
# 这个是把它放在后端运行了!
# ⚠️ &放进后台的命令,在连接断开时也可能被连带杀掉,所以才需要nohup和screen

进入后台运行#

①⭐&方法#

最常用的方法

  • 隔一个空格再去接&

  • jobs可以查看手动进入到后台的进程

Terminal window
[root@oldboy ~]# sleep 999 &
[1] 2781
# [1]表示手动进入到后台的第1个进程
# 2781表示进程号
[root@oldboy ~]# sleep 999 &
[2] 2782
'这个同理为第二个...'
[root@oldboy ~]# jobs
[1]- Running sleep 999 &
[2]+ Running sleep 999 &
Terminal window
jobs # 列出当前shell的所有后台作业
jobs -l # 显示详细信息,包括PID
'主要是这个PID'
[root@Rocky10 ~]# sleep 33 &
[1] 4190
[root@Rocky10 ~]# jobs
[1]+ Running sleep 33 &
[root@Rocky10 ~]# jobs -l
[1]+ 4190 Running sleep 33 &

②nohup命令和&方法#

Terminal window
1)默认输出到当前目录的nohup.out
[root@oldboy ~]# nohup ping -c5 www.baidu.com &
[1] 2860
[root@oldboy ~]# nohup: ignoring input and appending output to 'nohup.out'
# 默认追加到这个文件中
[1]+ Done nohup ping -c5 www.baidu.com
[root@oldboy ~]# cat ./nohup.out
# 当前目录下
PING www.a.shifen.com (39.156.70.239) 56(84) bytes of data.
64 bytes from 39.156.70.239 (39.156.70.239): icmp_seq=1 ttl=128 time=15.1 ms
64 bytes from 39.156.70.239 (39.156.70.239): icmp_seq=2 ttl=128 time=16.8 ms
64 bytes from 39.156.70.239 (39.156.70.239): icmp_seq=3 ttl=128 time=27.6 ms
64 bytes from 39.156.70.239 (39.156.70.239): icmp_seq=4 ttl=128 time=15.0 ms
64 bytes from 39.156.70.239 (39.156.70.239): icmp_seq=5 ttl=128 time=21.4 ms
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4008ms
rtt min/avg/max/mdev = 15.000/19.168/27.637/4.833 ms
  • 会在当前目录生成一个nohup.out,默认保存在这里!

  • 想要输出到其他文件中

    • nohup 命令 >新的文件 &

      • 覆盖 >

      • 追加 >>

Terminal window
2)重定向到指定文件
[root@oldboy ~]# nohup ping -c5 www.baidu.com > hh.txt &
[1] 2870
[root@oldboy ~]# nohup: ignoring input and redirecting stderr to stdout
# 覆盖写到hh.txt
[1]+ Done nohup ping -c5 www.baidu.com > hh.txt
[root@oldboy ~]# cat hh.txt
PING www.a.shifen.com (39.156.70.46) 56(84) bytes of data.
64 bytes from 39.156.70.46 (39.156.70.46): icmp_seq=1 ttl=128 time=10.1 ms
64 bytes from 39.156.70.46 (39.156.70.46): icmp_seq=2 ttl=128 time=10.9 ms
64 bytes from 39.156.70.46 (39.156.70.46): icmp_seq=3 ttl=128 time=9.17 ms
64 bytes from 39.156.70.46 (39.156.70.46): icmp_seq=4 ttl=128 time=9.37 ms
64 bytes from 39.156.70.46 (39.156.70.46): icmp_seq=5 ttl=128 time=12.6 ms
--- www.a.shifen.com ping statistics ---

③ctrl + z#

一般很少使用

并非撤销键

  • 让当前运行的命令或者服务进入后台挂起

    • 并非后台运行,而是挂起
  • 被暂停,对应ps aux进程状态的T

Terminal window
1)ctrl + c 是中止,并非我们要的
[root@oldboy ~]# ping -c10 www.baidu.com
^C
2)ctrl + z 挂起
[root@oldboy ~]# ping -c10 www.baidu.com
PING www.a.shifen.com (220.181.111.232) 56(84) bytes of data.
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=1 ttl=128 time=13.6 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=2 ttl=128 time=12.8 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=3 ttl=128 time=14.6 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=4 ttl=128 time=10.9 ms
^Z
[1]+ Stopped ping -c10 www.baidu.com
# 挂起,暂停
[root@oldboy ~]# ps aux | grep 'ping' | grep -v grep
root 1607 0.0 0.4 217980 4240 pts/0 T 16:06 0:00 ping -c10 www.baidu.com
# 对应T这个状态
Terminal window
[root@Rocky10 ~]# jobs
[1]+ Running sleep 33 &
# %n (n为jobs命令显示的作业号)
bg - 后台继续运行
bg # 恢复最近停止的后台作业
bg %1 # 恢复作业号为1的后台作业
fg - 前台运行作业
fg # 将最近的后台作业调到前台
fg %1 # 将作业号1调到前台
  • bg让“挂起暂停”的进程和服务,跑到后台运行

    • 两者结合相当于&,直接跑后台运行.

🌿 上岗条件不一样:

  • bg:作业必须是挂起(Stopped/T 状态)——已经在后台 Running 的作业,不用”继续”
  • fg:挂起 ✅ 或 后台 Running ✅ 都行——一律调到前台
  • 对挂起的作业:fg = 前台复活;bg = 后台复活,两个都能救
  • 对后台 Running 的作业(sleep 999 & 那种):fg 能拉到眼前,bg 没意义
Terminal window
3)ctrl + z挂起,暂停 + bg回到后台运行,两个加起来相当于&
[root@oldboy ~]# ping -c10 www.baidu.com
PING www.a.shifen.com (220.181.111.1) 56(84) bytes of data.
^Z
[1]+ Stopped ping -c10 www.baidu.com
# ctrl + z 挂起,暂停
[root@oldboy ~]# bg
[1]+ ping -c10 www.baidu.com &
'bg回到后台运行'
[root@oldboy ~]# fg
64 bytes from 220.181.111.1 (220.181.111.1): icmp_seq=1 ttl=128 time=15.2 ms
64 bytes from 220.181.111.1 (220.181.111.1): icmp_seq=2 ttl=128 time=16.8 ms
# 因为ping有输出,所以它一直在这里输出
  • 如果误触 ctrl + z 可以通过 fg 再次回到前台运行.
Terminal window
4)误触ctrl + z,用fg重新回到前台运行
[root@oldboy ~]# ping -c10 www.baidu.com
PING www.a.shifen.com (220.181.111.232) 56(84) bytes of data.
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=1 ttl=128 time=17.0 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=2 ttl=128 time=14.8 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=3 ttl=128 time=14.5 ms
^Z
[1]+ Stopped ping -c10 www.baidu.com
# 误触ctrl + z
[root@oldboy ~]# fg
ping -c10 www.baidu.com
# 重新回到前台运行
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=4 ttl=128 time=14.1 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=5 ttl=128 time=12.3 ms
64 bytes from 220.181.111.232 (220.181.111.232): icmp_seq=6 ttl=128 time=12.1 ms
^C
# ctrl + c 中止
--- www.a.shifen.com ping statistics ---

④⭐screen#

一般我们使用&,nohup方法让命令,服务进入后台运行,但是可能不稳定

  • 它是较为稳定的去运行后台的一些指令

  • 不运行大型的的服务,只是一些简单指令命令.

Terminal window
# 原理
# screen 本身并不会自动把里面的命令变成 "后台进程"
# 它只是提供了一个可脱离的虚拟终端环境
# 在 screen 会话里运行的命令,默认仍然是前台进程(相对于那个虚拟终端而言)
# 只是相对我们的屏幕终端,进入到了screen里面的虚拟终端"后台"
# 创建一个screen会话,只要会话还在,里面的命令就不会断
# 即使exit退出,只要screen -ls还能查到会话,命令就不会断
  1. 安装screen

yum -y install screen

Terminal window
[root@oldboy ~]# yum -y install screen
Last metadata expiration check: 3:23:27 ago on Wed 24 Dec 2025 01:33:45 PM CST.
Dependencies resolved.
=================================================================================================
Package Architecture Version Repository
=================================================================================================
Installing:
screen x86_64 1:4.8.0-7.ky10
Transaction Summary
=================================================================================================
Install 1 Package
  1. 创建命名会话
Terminal window
[root@oldboy ~]# screen -S test
# -S(大写)新建会话
# 直接进入到会话里面
[root@oldboy ~]# sleep 999
# 在会话里执行命令sleep 999
# ctrl+a+d脱离当前会话
[detached from 1580.test]
  • -S(大写)新建会话

  • 直接进入到会话里面

    • 执行命令sleep 999

    • ctrl+a+d脱离当前会话

  • 终端会显示:[detached from 1580.test]

    • 1580是会话ID

    • -S新建的会话名test

    • 用 . 点隔开

    • detached:安全可恢复

  1. ​退出会话
  • ctrl+a+d脱离当前会话

    • 正常退出,后面可以-r恢复
  • 强制退出,彻底结束

    • 后面-ls查不到这个会话,关闭了这个会话

      • ctrl+d

      • exit

    • ctrl+c是中止停止运行

      • 直接把进程关闭了
  1. 查看所有的会话
Terminal window
[root@oldboy ~]# screen -ls
There are screens on:
1876.oldboy (Detached)
1580.test (Attached)
2 Sockets in /run/screen/S-root.
# 前面是会话ID
# 后面是-S创建的会话名
Terminal window
[root@oldboy ~]# screen -ls
There are screens on:
1935.pts-2.oldboy (Detached)
1 Sockets in /run/screen/S-root.
# 默认screen进来不加-S
# 会话名是 终端名.主机名
# Detached 可恢复会话
'这个是默认screen进来'
  1. 两种状态详解

✅ (Detached):安全可恢复

  • 表示该 screen 会话,当前没有被任何终端连接.

  • 它在后台安静运行,处于空闲状态.

  • 你可以直接用 screen -r 恢复它,没有任何风险.

screen -r 会话名

screen -r 会话ID

✅ 这是最常见的理想状态 —— 断开后想回来继续工作.

⚠️ (Attached):已被占用

  • 表示该 screen 会话,当前正被另一个终端(或 SSH 会话)连接着.

  • 此时直接 screen -r 会失败

如何处理这种状态??

screen -dr 会话名或会话ID

  • -d:先将该会话从“Attached”状态 强制 detach

  • -r:然后立即 attach 到当前终端

💡 这是最常用、最安全的做法(前提是你确认没人正在用).


杀手三剑客#

kill — 按 PID 杀进程#

后跟 进程 ID,结束进程,最常用

Terminal window
kill [信号] PID
kill -l # 列出所有信号
场景命令效果
默认(-15)kill 1234平滑终止,内存数据写入磁盘
重载配置(-1)kill -1 1234重新加载,不断开连接
强制杀死(-9)kill -9 1234立刻终止,可能丢数据

(1)默认信号 kill -15

  • 平滑杀死进程,内存中的数据会写入到磁盘
  • 等同于 systemctl stop
  • kill 两次出现 No such process → 说明成功结束

(2)kill -1:重载配置

  • 重新加载进程,不会和用户断开
  • 等同于 systemctl reload

(3)kill -9:强制结束

  • 可能正在传输数据,直接就被杀死了
  • ① 强制结束后,进程可能起不来了,“受打击了”
  • ② 内存数据容易丢失
  • 尽量少用 kill -9

pkill — 模糊匹配进程名#

慎用,很少用;后跟进程名,支持正则、模糊匹配

Terminal window
pkill fire # 能杀 firefox(进程名含 "fire" 的全都匹配)
选项匹配对象精度风险
pkill(默认)进程名模糊中
pkill -f完整命令行最宽泛⚠️ 高
  • ps -ef 的 CMD 列显示完整命令行,但进程名是程序本身的名称(比如 sshd)
  • pkill 默认杀进程名(不是命令行),pkill -f 才杀命令行

进程名 vs 命令行

概念含义查看方式
进程名 (comm)程序的可执行文件名ps -eo comm
命令行 (cmd)完整的启动命令和参数ps -eo cmd
Terminal window
ps -eo pid,comm,cmd | grep sshd
# PID | comm | cmd
# 1234 | sshd | sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
# 同一进程的进程名和命令行,看到的内容是不一样的!

pkill -f#

  • pkill -f 匹配的是整个命令行字符串,比 pkill 更宽泛,更容易误杀
  • 适用场景:进程名跟程序名对不上号的情况
  • 比如 Java 程序——不管跑的是 Logstash 还是 ES,进程名统一都是 java,只有命令行才暴露身份

killall — 精准匹配进程名#

安全,常用;后跟全名,精准匹配进程名

Terminal window
killall firefox # 只杀 firefox
killall fire # ❌ 杀不到 firefox(不是全名)
命令匹配方式杀 firefox 的方式
killall精准匹配(≈ grep -w)killall firefox
pkill模糊匹配pkill fire ✅ 或 pkill firefox
Warning

⚠️ 特别警告:在 macOS 或 BSD 系统中,killall 的作用是”杀死所有进程”(用于关机), 不是按名字杀进程!


三剑客对比#

命令匹配对象精度对应 grep常用度
killPID最精准—⭐⭐⭐⭐
killall进程名(全名)精准grep -w⭐⭐⭐
pkill进程名(模糊)模糊grep⭐⭐
pkill -f完整命令行最宽泛grep(命令行)⭐

🌰 ElasticStack 场景实战

Terminal window
ES/Kibana → systemctl 管理 → systemctl stop elasticsearch
Filebeat → 裸进程 → killall -9 filebeat ✅️ 进程名就是 filebeat,精准
Logstash → 裸进程 → pkill -f -9 logstash ⚠️ 进程名是 java,只能匹配命令行
Caution

❌ 绝对禁止 killall -9 java 会同时杀掉 ES + Logstash + Tomcat + 任何 Java 进程

这就是为什么 Logstash 只能用 pkill -f 而不能用 killall java 的原因

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

Profile Image of the Author
久棹
不是先学好了再干,而是先干起来再学习,干中学!
分类
站点统计
文章
142
分类
19
标签
353
总字数
469,850
运行时长
0 天
最后活动
0 天前
文章目录