On 3/4/08, vivek khurana mailing.vivek@gmail.com wrote:
On Tue, Mar 4, 2008 at 3:39 AM, Agnello George agnello.dsouza@gmail.com 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" agnello.dsouza@gmail.com 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-notificatio...
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 " agnello.dsouza@gmail.com 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