[SATLUG] Cron Emails
John D Choate
jdchoate at gmail.com
Mon Mar 9 13:14:44 CDT 2009
On Monday 09 March 2009 09:05:44 Michael Rice wrote:
> Hey group. I am wanting to know if its possible to set the MAILTO on a per
> cron basis. I have some Cron jobs that need to go to our Sysadmin, and
> others that need to go to Accounting and a few that need to go to
> developers. Would I just need to export MAILTO before each job runs or is
> there more to it than that?
Not sure if this will help or not. I use webmin to administer a server and have used it to create several cron jobs with the option to send an email for each job.
You may be able to manually edit your cron jobs in /var/spool/cron as root. The cron jobs will be listed in files named for the user who runs the jobs.
In the following examples, I have 2 cron jobs, the first of which runs a script every 5 minutes to pipe various commands through cat to create a text file... the second job mails that text file to a user every 4 hours. BUT, on the second job, piping cat to mail to the user is part of the command I assigned as a cron job.
0,5,10,15,20,25,30,35,40,45,50,55 * * * * sh /home/username/Documents/uptime.sh #Write system uptime to text and html
0 1,5,9,13,17,21 * * * cat /var/www/html/uptime.txt | mail username at domain.com #Mail uptime.txt to username
I have other cron jobs which send results through email, but the mail command was not part of the command issued, rather it was defined by webmin when I set up the jobs. I cannot find where cron has saved that mail info for those jobs.
More information about the SATLUG