Skip to content

Instantly share code, notes, and snippets.

@dcragusa
Created September 7, 2018 12:45
Show Gist options
  • Save dcragusa/98968ac661c13ab6c3069065da8074b8 to your computer and use it in GitHub Desktop.
Save dcragusa/98968ac661c13ab6c3069065da8074b8 to your computer and use it in GitHub Desktop.
Kill a process (and any spawned subprocesses) by PID
echo killing
# Get progress group id from pid
PGID=$(ps opgid `cat ${PID_PATH}` | grep -o '[0-9]*')
# Kill the process group
kill -- -$PGID
echo killed
# Now that it's killed, don't forget to remove the PID file
rm ${PID_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment