Kill a 10 minute zombie process in Linux bash script

I have been very successful in regularizing yukondude . I am trying to kill processes that are older than 10 minutes. I already know what process identifiers are. I iterate over the array every 10 minutes to see if there are any protracted procs around and need to be killed. Anyone have quick thoughts on this?

ps -eo uid,pid,etime 3233332 | egrep ' ([0-9]+-)?([0-9]{2}:?){3}' | awk '{print $2}' | xargs -I{} kill {}
+3
source share
1 answer

Like real zombies, zombie processes cannot be killed - they are already dead.

They will disappear when their parent process calls wait()to get their exit code, or when their parent process exits.


, Zombie. bash script , :

ps -eo uid,pid,lstart |
    tail -n+2 |
    while read PROC_UID PROC_PID PROC_LSTART; do
        SECONDS=$[$(date +%s) - $(date -d"$PROC_LSTART" +%s)]
        if [ $PROC_UID -eq 1000 -a $SECONDS -gt 600 ]; then
            echo $PROC_PID
        fi
     done |
     xargs kill

, UID 1000, 10 (600 ). , PID - , ? , - .

+6

Source: https://habr.com/ru/post/1743910/


All Articles