[H-GEN] Cron Jobs and Logs

Greg Black gjb at gbch.net
Mon Feb 16 07:05:52 EST 2004


On 2004-02-16, Rick Phillips wrote:

> I have set up a cron job which updates my local mirror every day and I
> would like to have the server email me the logfile created as a result. 

Most versions of cron automatically mail any output to the user,
so this would be the simplest thing to do.

> I have looked at "man mail"
> but it is a bit obscure to me.

It can be done, but mail(1) is actually designed as a mail
reader, so it's a stretch to do what you want.

> I also run qmail and alternatively run e.g.
> 
> echo To: someone at someplace.com | /var/qmail/bin/qmail-inject

This is incomplete.  The following is intended as a starting
point, and will need you to work out the details.

    ( echo "To: me at my.com"
      echo "From: root at your.com"
      echo "Subject: Results of the cron job"
      echo
      hostname
    ) | qmail-inject 

This creates some useful headers for the message and gives it
the output of the "hostname" command as a body.  You'd replace
that last part by the stuff you want to run.

To see what's being done, if you don't grok shell scripts, just
replace the qmail-inject with cat.

Cheers, Greg




More information about the General mailing list