Hi all
I have a '/etc/cron.daily/push-to-backup' script which the content is:
#!/bin/bash /usr/bin/rsync [... long options line ...] echo "finished pushing to the backup"
Launched manually, it's OK.
Waiting for cron to execute it, In the "/var/log/cron", I see the starting time and the finish time, and I see it take about 10 minutes to make the job. That's very fine, it's the expected executioon time
The problem is: I get no EMail. In "/etc/cron.daily/", I also have "logwatch", whose EMail comes to me without problem. "/etc/aliases" is already setup to forward root and cron emails to my email adress. Testing the MTA (Exim) on command-line: success (anyway, logwatch also success on sending email)
On another centos5 machine, the same script, the mail is sent.
On the Centos 6: $ rpm -aq | grep cron crontabs-1.10-33.el6.noarch cronie-1.4.4-7.el6.x86_64 cronie-anacron-1.4.4-7.el6.x86_64
On the Centos 5: $ rpm -aq | grep cron crontabs-1.10-8 vixie-cron-4.1-81.el5 anacron-2.3-45.el5.centos
How to setup the Centos6 system so that the cron sends me an email the script output??
check out the crontab file if you have these,
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root ===========================> that's what you are looking for HOME=/
# run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly
------------ Banyan He Blog: http://www.rootong.com Email: banyan@rootong.com
On 2012-11-23 3:52 PM, Mihamina Rakotomandimby wrote:
Hi all
I have a '/etc/cron.daily/push-to-backup' script which the content is:
#!/bin/bash /usr/bin/rsync [... long options line ...] echo "finished pushing to the backup"
Launched manually, it's OK.
Waiting for cron to execute it, In the "/var/log/cron", I see the starting time and the finish time, and I see it take about 10 minutes to make the job. That's very fine, it's the expected executioon time
The problem is: I get no EMail. In "/etc/cron.daily/", I also have "logwatch", whose EMail comes to me without problem. "/etc/aliases" is already setup to forward root and cron emails to my email adress. Testing the MTA (Exim) on command-line: success (anyway, logwatch also success on sending email)
On another centos5 machine, the same script, the mail is sent.
On the Centos 6: $ rpm -aq | grep cron crontabs-1.10-33.el6.noarch cronie-1.4.4-7.el6.x86_64 cronie-anacron-1.4.4-7.el6.x86_64
On the Centos 5: $ rpm -aq | grep cron crontabs-1.10-8 vixie-cron-4.1-81.el5 anacron-2.3-45.el5.centos
How to setup the Centos6 system so that the cron sends me an email the script output??
On 23/11/2012 10:28, Banyan He wrote:
check out the crontab file if you have these,
If it's centos 6, maybe /etc/anacrontab
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root ===========================> that's what you are looking for HOME=/
# run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly
Banyan He Blog: http://www.rootong.com Email: banyan@rootong.com
On 2012-11-23 3:52 PM, Mihamina Rakotomandimby wrote:
Hi all
I have a '/etc/cron.daily/push-to-backup' script which the content is:
#!/bin/bash /usr/bin/rsync [... long options line ...] echo "finished pushing to the backup"
Launched manually, it's OK.
Waiting for cron to execute it, In the "/var/log/cron", I see the starting time and the finish time, and I see it take about 10 minutes to make the job. That's very fine, it's the expected executioon time
The problem is: I get no EMail. In "/etc/cron.daily/", I also have "logwatch", whose EMail comes to me without problem. "/etc/aliases" is already setup to forward root and cron emails to my email adress. Testing the MTA (Exim) on command-line: success (anyway, logwatch also success on sending email)
On another centos5 machine, the same script, the mail is sent.
On the Centos 6: $ rpm -aq | grep cron crontabs-1.10-33.el6.noarch cronie-1.4.4-7.el6.x86_64 cronie-anacron-1.4.4-7.el6.x86_64
On the Centos 5: $ rpm -aq | grep cron crontabs-1.10-8 vixie-cron-4.1-81.el5 anacron-2.3-45.el5.centos
How to setup the Centos6 system so that the cron sends me an email the script output??
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On 11/23/2012 12:18 PM, Birta Levente wrote:
check out the crontab file if you have these,
If it's centos 6, maybe /etc/anacrontab
I have "MAILTO=root" in the file. If I make a CLI test to mail to root, all is working.
Is there a special feature such as "it only mail if STDERR"? Because all the messages (rsync output + echo "foo") is to STDOUT.
I cant find any doc about that. I suspect the thing to mail only if it's an error message...
On Mon, Nov 26, 2012 at 09:32:37AM +0300, Mihamina Rakotomandimby wrote:
Is there a special feature such as "it only mail if STDERR"? Because all the messages (rsync output + echo "foo") is to STDOUT.
Nope. _ALL_ output, bother stdout and stderr, will be sent via mail to the owner of the crontab or the address specified in the MAILTO variable.
Please include the _full_ rsync command line.
John
On 11/26/2012 09:41 AM, John R. Dennison wrote:
On Mon, Nov 26, 2012 at 09:32:37AM +0300, Mihamina Rakotomandimby wrote:
Is there a special feature such as "it only mail if STDERR"? Because all the messages (rsync output + echo "foo") is to STDOUT.
Nope. _ALL_ output, bother stdout and stderr, will be sent via mail to the owner of the crontab or the address specified in the MAILTO variable. Please include the _full_ rsync command line.
Forget about it: the culprit was the Google App antispam. It sent all the message from this particular crontjob to tha "Spam" folder.
I'm going to fix the antispam settings of my account.
On 11/26/2012 06:32 AM, Mihamina Rakotomandimby wrote:
I have "MAILTO=root" in the file. If I make a CLI test to mail to root, all is working.
Is there a special feature such as "it only mail if STDERR"? Because all the messages (rsync output + echo "foo") is to STDOUT.
You can send the stdout to a log file, which will prevent an email from being sent on stdout contents. As long as you dont redirect stderr as well, cron will continue to send you emails on errors reported there
On Mon, Nov 26, 2012 at 12:32 AM, Mihamina Rakotomandimby mihamina@rktmb.org wrote:
I have "MAILTO=root" in the file. If I make a CLI test to mail to root, all is working.
Is there a special feature such as "it only mail if STDERR"? Because all the messages (rsync output + echo "foo") is to STDOUT.
I cant find any doc about that. I suspect the thing to mail only if it's an error message...
You can redirect stdout to /dev/null if you don't ever want it. Then cron will only send mail if something is written to stderr. If you want to collect stdout but discard it unless there is error output you'll have to mange a tmp file yourself.
Le ven. 23 nov. 2012 10:52:50 CET, Mihamina Rakotomandimby a écrit:
Hi all
I have a '/etc/cron.daily/push-to-backup' script which the content is:
#!/bin/bash /usr/bin/rsync [... long options line ...] echo "finished pushing to the backup"
Launched manually, it's OK.
Waiting for cron to execute it, In the "/var/log/cron", I see the starting time and the finish time, and I see it take about 10 minutes to make the job. That's very fine, it's the expected executioon time ...
Compare the execution time to the timeout option of your smtp server.
I don't know about exim, but on my postfix I added : smtpd_timeout = 30m
Another possibility is to "spool" the mail, something like : rsync ...options... 2>&1 > LOGFILE echo -e "finished pushing to the backup \n$LOGFILE"
hth,
Le ven. 23 nov. 2012 10:42:19 CET, Philippe Naudin a écrit:
... rsync ...options... 2>&1 > LOGFILE echo -e "finished pushing to the backup \n$LOGFILE"
Nonsense, sorry.
If the output is short, you can do : LOGS=$(rsync ... 2>&1) echo -e "finished pushing to the backup \n$LOGS"
I you expect longer output : rsync ...options... 2>&1 > LOGFILE echo -e "finished pushing to the backup" cat LOGFILE