IT/Script tueur de zombies

29 janvier 2020 Rédigé par Linuxine

#!/bin/bash

display_usage() {
	echo "This script search for zombie process and kill their parents"
}

display_usage

ZOMBIES=$(ps -A -ostat,ppid | grep -e '[zZ]'| awk '{ print $2 }')

if test -n "${ZOMBIES}"
then 
	echo "Zombies found : ${ZOMBIES}"

	echo "Do you want to kill the zombies ?"
		select yn in "Yes" "No"; do
		  case $yn in
			Yes ) for ZOMBIE in ${ZOMBIES};
				  do
					   echo "Killing ${ZOMBIE}"
					   kill -9  ${ZOMBIE}
				  done
				  break;;
			No ) break;;
		  esac
	    done
fi

Écrire un commentaire