Doc / Linux / the Daily Ping

``How I Work'' article #4

Here's an easy way to keep track of whether a computer is up and running, and how it's doing: have it send you email every day.

I was recently explaining to our system administrator at work how it was that I knew, before I came in this morning, that the mail spool on our gateway had filled up sometime on Sunday. It's easy, really: I just read my email before setting out for work, and saw that my system's automatic daily email had gotten bounced with a "disk full" error.

Having a machine send you daily email can give you a lot of information:

So, here's the script I run every day: it lives in a file called ~/bin/daily (because no matter where I am, I'm going to have a ~/bin/ directory for my personal scripts).

#!/bin/bash
#  $Id: daily,v 1.2 1999/06/28 02:31:33 steve Exp $
(date; w; df) | mail -s "STATUS:`hostname` `date`" \
    steve@home.example.org steve@work.example.com

There are a couple of subtle points here:

Here's the master crontab file, which I keep in ~/bin/crontab:

# NOTE: master is ~/bin/crontab
8 3 * * * $HOME/bin/daily

The note is so that when I look at my crontab with crontab -l I know where it came from -- I change this so rarely that I really need the reminder.

Coming Eventually

The next time I feel the need to work on this stuff, I'll make it self-installing, checking for a command-line argument like, e.g., --install and running crontab to install itself.


$Id: index.html,v 1.5 2003/11/22 17:27:19 steve Exp $
Stephen R. Savitzky <steve @ theStarport.org>