使用top工具,发现有大量僵尸进程
top - 05:32:34 up 6:21, 2 users, load average: 8.13, 6.15, 4.83
Tasks: 870 total, 1 running, 859 sleeping, 0 stopped, 10 zombie
%Cpu(s): 0.7 us, 0.3 sy, 0.0 ni, 94.2 id, 4.4 wa, 0.1 hi, 0.2 si, 0.0 st
MiB Mem : 127955.6 total, 106662.2 free, 16308.0 used, 5954.3 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 111647.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
354979 root 20 0 0 0 0 Z 0.0 0.0 0:00.03 git
355152 root 20 0 0 0 0 Z 0.0 0.0 0:00.00 git
532213 root 20 0 0 0 0 Z 0.0 0.0 0:00.04 git
532326 root 20 0 0 0 0 Z 0.0 0.0 0:00.00 git
541983 root 20 0 0 0 0 Z 0.0 0.0 0:00.03 git
542101 root 20 0 0 0 0 Z 0.0 0.0 0:00.00 git
670442 root 20 0 0 0 0 Z 0.0 0.0 0:00.03 git
670528 root 20 0 0 0 0 Z 0.0 0.0 0:00.00 git
672835 root 20 0 0 0 0 Z 0.0 0.0 0:00.04 git
#安装两个工具
[root@sc-midware-1 ~]# dnf install -y procps && dnf install psmisc -y
[root@sc-midware-1 ~]# pstree -apscl 354979
systemd,1 --switched-root --system --deserialize 31
└─containerd-shim,10835 -namespace k8s.io -id b8200d8cad653f1eeeae8afb7cd901b7d368a8b3381b4939563398075df8611c -address /run/containerd/containerd.sock
└─sleep,11681 --coreutils-prog-shebang=sleep /usr/bin/sleep 30000s
└─(git,354979)
发现僵尸进程是由expect调用git导致的
从网上找资料,发现expect退出的时候,需要等待杀死子进程,需要在expect中加入wait指令
function privateRepo(){
/usr/bin/expect