[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: email notification when a process ends?



On Wed, Apr 15, 2009 at 08:40:36PM +0000, Pedro Insua wrote:

>   Sorry.. I forgot 'sleep'
> 
> 
> ,----
> |   while true; do
> | 
> |     IDP=$(pidof your_process)
> | 
> |     if (( $? == 1 )) ; then
> |       echo "End your_process with pid:$IDP" | mail -s "subject text" user
> |     fi   
> |
> |     sleep 1
> | 
> |   done
> `----

Use 'ps fax | less'  to check for the right PID (if there's a loop there
you may be getting the wrong ID)

Now use:

#!/bin/sh
ID=that_id

while ps $ID >/dev/null 2>&1; do sleep 60; done
echo '' | mail -s 'process done' you@localhost



-- 
Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend


Reply to: