December 11th, 2003, 02:01 AM
Getting CRON to send me mail
I would like to have CRON send mail to my internet e-mail address.
I am using Redhat9.
The line I have in my /etc/crontab file is:
MAULTO=cmd | mail -s "cron report" email@example.com
So far it does not appear to be working.
This is the ONLY crontab file on my machine - i.e. I do not have any specific user crontabs set up that would override this one.
Any ideas on what I am missing here?
December 11th, 2003, 02:30 AM
Just as an addendum, I can use the mail command from the command line and send myself mail with no problem, so I know it is working correctly.
The problem seems to be getting the system to send it to me automatically.
Ideally, I would like to have my cron reports and logs sent to me via the internet.
Any guidance as to what I may be missing here is greatly appreciated.
December 11th, 2003, 02:33 AM
Well from the looks of it you didnt specify it to email you anything...
You are calling the mail program with the subject and who to send it to, then mail drops into 'interactive' mode and waits for you to enter the body of the text and then tell the mail application that your done...
Hope this helps you out a bit... Yes i know its vague but im not feeling like looking up the info right now thats for you to do =P
<chsh> I've read more interesting technical discussion on the wall of a public bathroom than I have at AO at times
December 11th, 2003, 02:38 AM
Thanks Dark - I have read man pages etc. until my eyes are crossed.
What you are saying makes sense - my understanding was that by default the MAILTO line in crontab would by default send the cron reports. Meaning that would be the body of the message.
I will do some more research.
I appreciate the reply.
December 11th, 2003, 08:29 AM
Baiscally, you want to 'pipe' a command to mail and send it to your email address (as explained by Darksnake).
A very simple example would be to send the output of df -h to yourself once per day as in this example....
30 07 * * * /bin/df -h | mail -s "Daily Disk Usage Stats on `uname -n`" firstname.lastname@example.org
Which in english means at 07:30, run the command 'df -h' and send the output in an email to email@example.com with subject "Daily Disk Usage Stats on [short hostname]"
Hope that helps...
Get OpenSolaris http://www.opensolaris.org/