Ghetto monitoring

I have a server with hardware problems so I wrote a quicky one line bash command to monitor it.

while /bin/true; do ping -c1; if [ $? -ne 0 ] ; then echo "Server is down" | mutt -s Outage ; break; fi ; sleep 30 ; done;
Leave A Reply - 1 Reply
Zimzat 2007-10-19 04:46am - - Logged IP:

If you don't mind waiting for the first iteration to run then you can use the sleep as the while condition.

while sleep 1; do echo 'Yes Master'; done

I'm going to have to remember this the next time I'm trying to watch the output of a command.

All content licensed under the Creative Commons License