Skip to content

Instantly share code, notes, and snippets.

@schtobia
Last active August 1, 2016 07:13
Show Gist options
  • Save schtobia/2740ee90e13a7f27ca18811f1e1e9b29 to your computer and use it in GitHub Desktop.
Save schtobia/2740ee90e13a7f27ca18811f1e1e9b29 to your computer and use it in GitHub Desktop.
Kill all zombies, with increasing vigor
#! /bin/sh
for current_signal in HUP TERM KILL SEGV;
do
ZOMBIES=$(ps -A -ostat,ppid | sed -rn 's/^[zZ][^[:space:]]*[[:space:]]*([0-9]+)/\1/p' | sort -nu);
[ -n "$ZOMBIES" ] && { kill -s $current_signal $ZOMBIES; sleep 2; } || true;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment