Skip to content

Instantly share code, notes, and snippets.

@noisychannel
Last active August 29, 2015 14:19
Show Gist options
  • Save noisychannel/35d009ccab805b106b9b to your computer and use it in GitHub Desktop.
Save noisychannel/35d009ccab805b106b9b to your computer and use it in GitHub Desktop.
Monitor a process
#!/usr/bin/env bash
if [ $# -lt 1 ]; then
echo "Please enter the process ID to monitor:"
exit 1;
fi
#TODO: Change email
[email protected]
PID=$1
PNAME="$(cat /proc/$1/cmdline)"
while [ -e /proc/$PID ] ; do
sleep 30 # chage it to 30 or any other time in seconds (600 seconds=10 minutes!)
done
echo "$1 Process done" | mail -s "$PNAME process finished" $EMAIL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment