侧边栏壁纸
博主头像
AngusWong's博客 博主等级

行动起来,活在当下

  • 累计撰写 25 篇文章
  • 累计创建 26 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

解决Linux系统进程杀掉后又自动启动的问题

Administrator
2024-10-02 / 0 评论 / 0 点赞 / 14 阅读 / 0 字

一、ps -aux 查找到对应进程pid号

[root@www ~]# ps -aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
mysql 9844 10.2 8.7 2215852 704072 ? Sl 13:30 24:42 /www/server/mys
www 13454 2.5 0.4 287960 32276 ? S 14:16 4:54 php-fpm: pool w
www 13448 2.4 0.3 284980 29452 ? S 14:16 4:52 php-fpm: pool w
www 13449 2.4 0.3 286952 31444 ? S 14:16 4:51 php-fpm: pool w
www 13450 2.4 0.3 286980 31508 ? S 14:16 4:51 php-fpm: pool w
www 13451 2.4 0.3 287028 30948 ? S 14:16 4:48 php-fpm: pool w
www 13452 2.4 0.4 287856 32292 ? S 14:16 4:50 php-fpm: pool w
www 13453 2.4 0.3 287092 31552 ? S 14:16 4:48 php-fpm: pool w
www 13455 2.4 0.3 286948 31468 ? S 14:16 4:52 php-fpm: pool w
www 13456 2.4 0.3 284964 29472 ? S 14:16 4:46 php-fpm: pool w
www 13457 2.4 0.4 288024 32312 ? S 14:16 4:50 php-fpm: pool w
www 13458 2.4 0.3 286952 31476 ? S 14:17 4:52 php-fpm: pool w
www 13479 2.4 0.3 287032 31548 ? S 14:19 4:46 php-fpm: pool w
www 13485 2.4 0.3 284908 29412 ? S 14:19 4:44 php-fpm: pool w
www 13486 2.4 0.3 287012 31544 ? S 14:19 4:42 php-fpm: pool w
www 13487 2.4 0.4 287964 32288 ? S 14:19 4:43 php-fpm: pool w
www 25458 2.4 0.3 287012 31464 ? S 14:25 4:31 php-fpm: pool w
www 25461 2.4 0.4 287960 32192 ? S 14:25 4:29 php-fpm: pool w
www 25459 2.3 0.3 286980 31004 ? S 14:25 4:28 php-fpm: pool w
www 25460 2.3 0.3 287020 31020 ? S 14:25 4:28 php-fpm: pool w
www 25763 2.3 0.3 287016 31488 ? S 14:49 3:45 php-fpm: pool w
www 25764 2.2 0.3 286948 31424 ? S 14:49 3:43 php-fpm: pool w
www 25769 2.2 0.3 287208 31732 ? S 14:49 3:44 php-fpm: pool w
www 25770 2.2 0.3 286952 31424 ? S 14:49 3:41 php-fpm: pool w
www 25771 2.2 0.3 286956 31460 ? S 14:49 3:40 php-fpm: pool w
www 25806 2.2 0.3 287028 31556 ? S 14:50 3:41 php-fpm: pool w
www 25808 2.2 0.4 287880 32180 ? S 14:50 3:39 php-fpm: pool w
www 26436 2.2 0.4 287884 32184 ? S 15:40 2:31 php-fpm: pool w
www 26437 2.2 0.3 286956 30832 ? S 15:40 2:30 php-fpm: pool w
www 26438 2.2 0.3 287080 31536 ? S 15:40 2:29 php-fpm: pool w
www 26439 2.2 0.3 287016 31468 ? S 15:40 2:29 php-fpm: pool w
emqx 951 1.8 1.9 2420276 157116 ? Ssl 13:08 4:59 emqx -Bd -spp t
root 3424 1.6 0.6 1344976 48268 ? Sl 13:09 4:14 /www/server/pan
redis 1073 0.5 1.5 301476 127084 ? Ssl 13:08 1:24 /www/server/red
www 1147 0.4 0.5 193384 46388 ? S 13:08 1:08 nginx: worker p
www 1151 0.4 0.5 193384 47680 ? S 13:08 1:14 nginx: worker p
root 28010 0.4 0.0 0 0 ? S 17:21 0:02 [kworker/1:2]
root 28653 0.3 0.0 0 0 ? S 17:31 0:00 [kworker/1:1]
root 9 0.2 0.0 0 0 ? S 13:07 0:41 [rcu_sched]
root 3221 0.2 0.8 572416 66336 ? Sl 13:09 0:46 /www/server/pan
root 12812 0.2 0.3 1029404 31028 ? Ssl 13:57 0:35 oneav -threatbo
root 273 0.1 0.0 0 0 ? S 13:07 0:19 [jbd2/vda1-8]
root 1 0.0 0.0 125484 3828 ? Ss 13:07 0:03 /usr/lib/system
root 2 0.0 0.0 0 0 ? S 13:07 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< 13:07 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S 13:07 0:01 [ksoftirqd/0]
root 7 0.0 0.0 0 0 ? S 13:07 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S 13:07 0:00 [rcu_bh]
root 10 0.0 0.0 0 0 ? S< 13:07 0:00 [lru-add-drain]
root 11 0.0 0.0 0 0 ? S 13:07 0:00 [watchdog/0]
root 12 0.0 0.0 0 0 ? S 13:07 0:00 [watchdog/1]

二、cd /proc/PID

[root@www ~]# cd /proc/9844
[root@www 9844]# ll
total 0
dr-xr-xr-x   2 mysql mysql 0 Oct  2 17:34 attr
-rw-r--r--   1 root  root  0 Oct  2 17:34 autogroup
-r--------   1 root  root  0 Oct  2 17:34 auxv
-r--r--r--   1 root  root  0 Oct  2 17:34 cgroup
--w-------   1 root  root  0 Oct  2 17:34 clear_refs
-r--r--r--   1 root  root  0 Oct  2 13:33 cmdline
-rw-r--r--   1 root  root  0 Oct  2 13:33 comm
-rw-r--r--   1 root  root  0 Oct  2 17:34 coredump_filter
-r--r--r--   1 root  root  0 Oct  2 17:34 cpuset
lrwxrwxrwx   1 root  root  0 Oct  2 17:34 cwd -> /www/server/data
-r--------   1 root  root  0 Oct  2 17:34 environ
lrwxrwxrwx   1 root  root  0 Oct  2 13:31 exe -> /www/server/mysql/bin/mysqld
dr-x------   2 root  root  0 Oct  2 13:33 fd
dr-x------   2 root  root  0 Oct  2 17:34 fdinfo
-rw-r--r--   1 root  root  0 Oct  2 17:34 gid_map
-r--------   1 root  root  0 Oct  2 13:31 io
-r--r--r--   1 root  root  0 Oct  2 17:34 limits
-rw-r--r--   1 root  root  0 Oct  2 17:34 loginuid
dr-x------   2 root  root  0 Oct  2 17:34 map_files
-r--r--r--   1 root  root  0 Oct  2 17:34 maps
-rw-------   1 root  root  0 Oct  2 17:34 mem
-r--r--r--   1 root  root  0 Oct  2 17:34 mountinfo
-r--r--r--   1 root  root  0 Oct  2 17:34 mounts
-r--------   1 root  root  0 Oct  2 17:34 mountstats
dr-xr-xr-x   5 mysql mysql 0 Oct  2 17:34 net
dr-x--x--x   2 root  root  0 Oct  2 17:34 ns
-r--r--r--   1 root  root  0 Oct  2 17:34 numa_maps
-rw-r--r--   1 root  root  0 Oct  2 17:34 oom_adj
-r--r--r--   1 root  root  0 Oct  2 17:34 oom_score
-rw-r--r--   1 root  root  0 Oct  2 17:34 oom_score_adj
-r--r--r--   1 root  root  0 Oct  2 17:34 pagemap
-r--------   1 root  root  0 Oct  2 17:34 patch_state
-r--r--r--   1 root  root  0 Oct  2 17:34 personality
-rw-r--r--   1 root  root  0 Oct  2 17:34 projid_map
lrwxrwxrwx   1 root  root  0 Oct  2 17:34 root -> /
-rw-r--r--   1 root  root  0 Oct  2 17:34 sched
-r--r--r--   1 root  root  0 Oct  2 17:34 schedstat
-r--r--r--   1 root  root  0 Oct  2 17:34 sessionid
-rw-r--r--   1 root  root  0 Oct  2 17:34 setgroups
-r--r--r--   1 root  root  0 Oct  2 17:34 smaps
-r--r--r--   1 root  root  0 Oct  2 17:34 stack
-r--r--r--   1 root  root  0 Oct  2 13:30 stat
-r--r--r--   1 root  root  0 Oct  2 13:30 statm
-r--r--r--   1 root  root  0 Oct  2 13:34 status
-r--r--r--   1 root  root  0 Oct  2 17:34 syscall
dr-xr-xr-x 121 mysql mysql 0 Oct  2 13:39 task
-r--r--r--   1 root  root  0 Oct  2 17:34 timers
-rw-r--r--   1 root  root  0 Oct  2 17:34 uid_map
-r--r--r--   1 root  root  0 Oct  2 17:34 wchan

三、cat status,找到父进程的PPID号

[root@www 9844]# cat status
Name:   mysqld
Umask:  0026
State:  S (sleeping)
Tgid:   9844
Ngid:   0
Pid:    9844
PPid:   7931
TracerPid:      0
Uid:    1001    1001    1001    1001
Gid:    1001    1001    1001    1001
FDSize: 512
Groups: 1001 
VmPeak:  2215856 kB
VmSize:  2215852 kB
VmLck:         0 kB
VmPin:         0 kB
VmHWM:    706120 kB
VmRSS:    706120 kB
RssAnon:          695452 kB
RssFile:           10668 kB
RssShmem:              0 kB
VmData:  2135320 kB
VmStk:       132 kB
VmExe:     22108 kB
VmLib:      9028 kB
VmPTE:      1740 kB
VmSwap:        0 kB
Threads:        119
SigQ:   0/31202
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000084007
SigIgn: 0000000000003006
SigCgt: 00000001800006e8
CapInh: 0000000000000000
CapPrm: 0000000000000000
CapEff: 0000000000000000
CapBnd: 0000001fffffffff
CapAmb: 0000000000000000
NoNewPrivs:     0
Seccomp:        0
Speculation_Store_Bypass:       vulnerable
Cpus_allowed:   3
Cpus_allowed_list:      0-1
Mems_allowed:   00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001
Mems_allowed_list:      0
voluntary_ctxt_switches:        26265
nonvoluntary_ctxt_switches:     96

可以看到示例持PPid: 7931

四、先杀掉父进程:kill -9 PPID

kill -9 7931

五、再杀掉子进程:kill -9 PID

kill -9 9844

 

0

评论区