I want to run cat/proc/mdstat as root as a cron job once a day and have it email the results to my work email account. Checked crontab -e, etc, but am still very confused. The MAILTO= seems to be only for a user. If I do a crontab -e MAILTO= "mylogon@comcast.net" 5 0 * * * cat /proc/mdstat Will this work? If not, how would I do it or is there any way to send all root email to a real email address? I remember seeing something about this in the installation, but can't find it anymore. Have also tried mail from the command line and it works to my real email address. Art
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Thursday 2005-10-13 at 16:09 -0700, Art Fore wrote:
I want to run cat/proc/mdstat as root as a cron job once a day and have it email the results to my work email account. Checked crontab -e, etc, but am still very confused. The MAILTO= seems to be only for a user.
If I do a crontab -e
MAILTO= "mylogon@comcast.net" 5 0 * * * cat /proc/mdstat
You'd better create a script that does exactly what you want, and set that script to be run from cron. The mailto setting affects every job defined, and by default (in suse settings) only sends something on errors.
Will this work? If not, how would I do it or is there any way to send all root email to a real email address? I remember seeing something about this in the installation, but can't find it anymore.
It's an alias.
Have also tried mail from the command line and it works to my real email address.
As long as your postfix/sendmail/qmail server is ok, it will work. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFDTv7wtTMYHG2NR9URAhVVAJ9h7uBabN6m7EL5BOZexxd4RHpH1QCdEhrk Cqac0UIHd0KN1+JuMrNzKds= =BoCt -----END PGP SIGNATURE-----
From: "Carlos E. R."
Date: Fri, 14 Oct 2005 02:42:21 +0200 (CEST) To: SLE Subject: Re: [SLE] crontab +email -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
The Thursday 2005-10-13 at 16:09 -0700, Art Fore wrote:
I want to run cat/proc/mdstat as root as a cron job once a day and have it email the results to my work email account. Checked crontab -e, etc, but am still very confused. The MAILTO= seems to be only for a user.
If I do a crontab -e
MAILTO= "mylogon@comcast.net" 5 0 * * * cat /proc/mdstat
You'd better create a script that does exactly what you want, and set that script to be run from cron. The mailto setting affects every job defined, and by default (in suse settings) only sends something on errors.
As I think about it, Carlos is right. I'd do something like this: #!/bin/bash # Define a tempfile - date +%s outputs seconds since 00:00:00 01-01-1970 # and so ensures uniqueness TEMPFILE="/tmp/mdstat.`date +%s`" # Put mdstat output into a tempfile cat /proc/mdstat >> ${TEMPFILE} # cat the tempfile, and pipe it to mail (actually, nail) # -r "some@somewhere.com" defines the sender address # -s "some subject" defines the subject line # and the destination address goes after the subject cat ${TEMPFILE} | mail -r "fromaddress@someserver.com" -s "mdstat output: `date +%D`" "toaddress@someserver.com" # Get rid of the tempfile rm ${TEMPFILE} # Exit cleanly exit 0 ########################## Done here And, if you want to be really smart about it -- you'll set this to be executable and put it into the directory /etc/cron.daily/ -- then it'll be run each day at (I believe) 4 AM. (Just put the script into that directory -- no need for a crontab line).
From: Art Fore
Date: Thu, 13 Oct 2005 16:09:13 -0700 To: Subject: [SLE] crontab +email I want to run cat/proc/mdstat as root as a cron job once a day and have it email the results to my work email account. Checked crontab -e, etc, but am still very confused. The MAILTO= seems to be only for a user.
If I do a crontab -e
MAILTO= "mylogon@comcast.net" 5 0 * * * cat /proc/mdstat
Will this work? If not, how would I do it or is there any way to send all root email to a real email address? I remember seeing something about this in the installation, but can't find it anymore.
Have also tried mail from the command line and it works to my real email address.
Art
Yes, that should work. It's also possible to have all mail to root go to a real e-mail address (indeed, it's advisable). Edit the file /etc/aliases and add a line like this: root: mylogon@comcast.net Then save, and at the command line run the command `newaliases`. All mail to root will then go to your comcast address.
participants (3)
-
Art Fore
-
Carlos E. R.
-
Ian Marlier