[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 02:05:56PM -0500, Zhengquan Zhang wrote:
> > ,----
> > |   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
> > `----
> 
> I tested this, it runs great, but it would send me more than one
> duplicated emails. Is there a way to break after the first email is sent
> or something?


  Yes.. i thought like a daemon.. but yes, no problem to do it..

  #!/bin/bash

  IDP=0

  while (( IDP == 0 )); do
  
    IDP=$(pidof your_process)
    if (( $? == 1 )) ; then
       echo "End your_process with pid:$IDP" | mail -s "subject text" user
       IDP=1
    fi     
    sleep 1
  done

  exit 0
 
> 
> Thanks,
> 

  You must read the ABS-Guide , and other documents abouta shell
  programming. It's really a good thing. 

-- 
Porqué loitar e matar, se podes amar e sonhar

/"\
\ /  CAMPANHA DA FITA ASCII - CONTRA MAIL HTML
 X   ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
/ \


Reply to: