cordump.com

TIP: Are we there yet part 2, using a watch dog

by daven on Jan.22, 2008, under Automation, General System Administration, Life in General, Quick Tips

As a follow up to the previous tip on getting notified. What do you do when you have an already running process that you would like have notify you when it completes?
So you kicked off this update that was only supposed to take a few minutes but now an hour later it is still running and you are tired of having to check up on it, wouldn’t it be nice if you could just get a nice little e-mail letting you know when its done. Well, this little one liner just might make your day, ok maybe your hour…

while [ $(ps auxww | grep -i SOMEPROCESS | grep -v grep > /dev/null; echo $?) -eq 0 ]; do echo -n “.”; sleep 5; done; echo `/bin/date` | mail -s “SOMEPROCESS has completed” me@example.com

This little ditty will print a “.” every 5 seconds while the process is running, then when it completes will shoot you a nice little e-mail with the time it completed in the body. Now just don’t forget to the processes in screen so they can keep running even if you get disconnected.


1 Comment for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...