#!/bin/ksh # date_ps_ef.ksh # Report on world.php mimetype="text/html" emailfrom="rmetcalfe@rjmprogramming.com.au" emailto="rmetcalfe15@gmail.com" emailcc="rmetcalfe@rjmprogramming.com.au" subjmiddle="Date ps-ef world.php Report" lastcur="" while [ 0 -lt 1 ]; do cur="`ps -ef | grep '/world.php' | grep -v 'grep ' | wc -l | tr -d ' '`" echo "`date` $cur" if [ "$lastcur" != "$cur" ]; then if [ -z "$lastcur" ]; then echo "`ps -ef | grep '/world.php' | grep -v 'grep '`" > date_ps_ef_first.txt echo -e "Content-Type: ${mimetype}\nFrom: ${emailfrom}\nto: ${emailto}\ncc: ${emailcc}\nSubject: First ${subjmiddle} at `date`\n\n

First First ${subjmiddle} at `date`

`cat date_ps_ef_first.txt | sed '/^/s//<\/tr>/g'`
UIDPIDPPIDCSTIMETTYTIMECMD
/g' | sed 's/ \{1,\}/<\/td>/g' | awk '{ t=0; while (getline \$0) { if (t == 0) { print \"
" | sendmail -t -f ${emailto} else echo "`ps -ef | grep '/world.php' | grep -v 'grep '`" > date_ps_ef_next.txt echo -e "Content-Type: ${mimetype}\nFrom: ${emailfrom}\nto: ${emailto}\ncc: ${emailcc}\nSubject: Changed First ${subjmiddle} at `date`\n\n

Changed Date ps-ef world.php Report at `date`

" | sendmail -t -f ${emailto} cat date_ps_ef_next.txt > date_ps_ef_first.txt fi lastcur="$cur" fi # ps -ef | grep '/world.php' | grep -v 'grep ' sleep 30 done exit