On 3/4/08, vivek khurana <[EMAIL PROTECTED]> wrote:
>
> On Tue, Mar 4, 2008 at 3:39 AM, Agnello George <[EMAIL PROTECTED]>
> wrote:
> > HI
> >
> >  I have a small query !! I need to write a script whenever there is an
> >  error generated in the spamd.log  or any general log file to send me a
> >  mail only once, the bellow script is what i came u with but i doubt it
> >  would work.
> >
> >  if [ $(grep -e "unable to start service" /var/log/spamd.log)  = 1 ] ;
> then
> >  mail -s " pls check server IP 203.185.XXX>XXX" [EMAIL PROTECTED]
> >  fi
>
> You are almost there. For synchronous emailing you will need to un the
> script as a daemon. Have a look at this blog post for more details
>
>
> http://www.johnandcailin.com/blog/john/how-setup-real-time-email-notification-critical-syslog-events


 I finally came up with my own script to do this

#!/bin/sh -x

if [ $(tac  /var/log |grep -e "error: syswrite()"  | wc -l ) = 0 ] ; then
exit 1
else
echo "your mailserver is down" |mail -s " pls check server ip
216.185.xxx.xxx " [EMAIL PROTECTED]
fi
  then  i add a crontab to run for ever 10 min

crontab -e
10 * * * * /your/location/of/script


 if there is an easier way.... kindly tell me !!!

Thanks for all the help

-- 
> Regards
> Agnello Dsouza
> www.linux-vashi.blogspot.com
> www.bible-study-india.blogspot.com
-- 
http://mm.glug-bom.org/mailman/listinfo/linuxers

Reply via email to