Mihamina Rakotomandimby
2012-Nov-23 07:52 UTC
[CentOS] centos 6.3, cron and mail script output
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?? -- RMA.
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 at 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?? >
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, -- Philippe Naudin UMR MISTEA : Math?matiques, Informatique et STatistique pour l'Environnement et l'Agronomie INRA, b?timent 29 - 2 place Viala - 34060 Montpellier cedex 2 t?l: 04.99.61.26.34, fax: 04.99.61.29.03, m?l: naudin at supagro.inra.fr