Sometimes you want to keep tabs on a long running process and get notified by email when it is done. This is an example of just that.
#!/bin/bash pid=$1 me="$(basename $0)($$):" if [ -z "$pid" ] then echo "$me a PID is required as an argument" >&2 exit 2 fi name=$(ps -p $pid -o comm=) if [ $? -eq 0 ] then echo "$me waiting for PID $pid to finish ($name)" while ps -p $pid > /dev/null; do sleep 1; done; else echo "$me failed to find process with PID $pid" >&2 exit 1 fi ## I used a python mailer but mostlikely this will be mail or mailx. python pymail.py $pid