Skip to content

Instantly share code, notes, and snippets.

@abdallah
Last active December 14, 2015 21:29
Show Gist options
  • Save abdallah/5151711 to your computer and use it in GitHub Desktop.
Save abdallah/5151711 to your computer and use it in GitHub Desktop.
Email me when a long running process is finished
PROCESS=$1
SLEEP_TIME=60
EMAIL_ADDRESS=abdallah@example.com
while [ -n "$(pidof $PROCESS)" ]; do sleep $SLEEP_TIME; done; echo "Finished ..." | mail -s "Work finished" $EMAIL_ADDRESS
@genright
Copy link

Many ways to skin this cat right? Sorry pardon the grossness. May also want to check on the state of the process in case it zombies out? You can use $PID if this is embedded in the script itself

while [[ ( -d /proc/$PID ) && ( -z $(grep zombie /proc/$PID/status) ) ]]
do ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment