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 1.2.3.4 -c1; if [ $? -ne 0 ] ; then echo "Server is down" | mutt -s Outage email@domain.com ; break; fi ; sleep 30 ; done;
Leave A Reply - 1 Reply
Replies
Zimzat 2007-10-19 04:46am - livejournal.com - Logged IP: 24.253.80.162

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