You are not logged in.
Hi. I have several scripts in /etc/cron.hourly/ For example my update_website.sh
#!/bin/bash
rsync -e ssh -avz /home/http/content --exclude "*bak" --exclude "*~" myuser@mysite.com:/usr/users/myuser/WWW
The script executes nicely on its own, but never gets executed via cron, as inteded. I have
$ ls -l
-rwxr-xr-x 1 root root 590 2009-03-21 14:57 /etc/cron.hourly/upload_website.sh
and
$ sudo crontab -l
Password:
#
# DO NOT EDIT THIS FILE MANUALLY!! USE crontab -e INSTEAD.
#
# <minute> <hour> <day> <month> <dow> <command>
01 * * * * /usr/sbin/run-cron /etc/cron.hourly
02 00 * * * /usr/sbin/run-cron /etc/cron.daily
22 00 * * 0 /usr/sbin/run-cron /etc/cron.weekly
42 00 1 * * /usr/sbin/run-cron /etc/cron.monthly
Any ideas?
Offline
Have you checked /var/log/crond for errors?
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Just a bunch of sendmail errors (I really should set up mail to catch all these messages...)
$ cat /var/log/crond
22-Mar-2009 00:04 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 00:22 FILE /var/spool/cron/root USER root pid 12775 cmd /usr/sbin/run-cron /etc/cron.weekly
22-Mar-2009 11:22 /usr/sbin/crond V3.2 dillon, started
22-Mar-2009 12:01 FILE /var/spool/cron/root USER root pid 3447 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 12:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 13:01 FILE /var/spool/cron/root USER root pid 7290 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 13:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 14:01 FILE /var/spool/cron/root USER root pid 8641 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 14:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 15:01 FILE /var/spool/cron/root USER root pid 9946 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 15:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 16:01 FILE /var/spool/cron/root USER root pid 10501 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 16:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 17:01 FILE /var/spool/cron/root USER root pid 11820 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 17:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 18:01 FILE /var/spool/cron/root USER root pid 12861 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 18:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 19:01 FILE /var/spool/cron/root USER root pid 14935 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 19:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 20:01 FILE /var/spool/cron/root USER root pid 20317 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 20:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 21:01 FILE /var/spool/cron/root USER root pid 23332 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 21:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 22:01 FILE /var/spool/cron/root USER root pid 23348 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 22:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null22-Mar-2009 23:01 FILE /var/spool/cron/root USER root pid 24723 cmd /usr/sbin/run-cron /etc/cron.hourly
22-Mar-2009 23:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null23-Mar-2009 09:10 /usr/sbin/crond V3.2 dillon, started
23-Mar-2009 22:26 /usr/sbin/crond V3.2 dillon, started
23-Mar-2009 23:01 FILE /var/spool/cron/root USER root pid 20428 cmd /usr/sbin/run-cron /etc/cron.hourly
23-Mar-2009 23:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null24-Mar-2009 00:01 FILE /var/spool/cron/root USER root pid 24315 cmd /usr/sbin/run-cron /etc/cron.hourly
24-Mar-2009 00:01 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null24-Mar-2009 00:02 FILE /var/spool/cron/root USER root pid 26765 cmd /usr/sbin/run-cron /etc/cron.daily
24-Mar-2009 00:04 unable to exec /usr/sbin/sendmail -t, user -oem, output to sink null
Offline
Maybe you should try restarting the crond daemon?
/etc/rc.d/crond restart
I say this because the manpage for crond says that only the /etc/crond.d directory is checked by default for any changes. (And htop for me says that /usr/sbin/crond is running without any options, meaning that it's only checking /etc/crond.d for changes while it's running).
Or you could force the crond daemon to check the directory by passing the -c flag. (see man crond) Although, this means you'd have to pass this flag every time Arch boots and loads crond (and I'm not familiar with implementing this in the /etc/rc.conf file).
If that doesn't work, perhaps you should try editing the cronfile for root directly with
sudo crontab -e
and manually adding an entry in the cron format, pointing it to your custom shell script.
Last edited by listdata (2009-04-10 20:46:00)
Offline
Hi androith,
Crond sends the outputs of the scheduled job (in your case the output from the shell script) via email to the user which owns the crond process. I believe that it is done via a pipe and even if I'm not entirely sure, that the listening part of the pipe has to be ready before the sendind part is allowed to start.
So if the listening part here is sendmail which isn't configured on your setup as you mentionned, I guess the sending part (your script) is prevented to run by the pipe mechanism, because it would cause a broken pipe.
So you could either set up sendmail or I believe that the "send an email upon job completion" default crond option can be disabled, maybe try lookin at the man page about it ?
Hope that helps
Offline
Hi,
Tried adding full path to rsync? Shouldn't be why its not working, but.....
#!/bin/bash
/usr/bin/rsync -e ssh -avz /home/http/content --exclude "*bak" --exclude "*~" myuser@mysite.com:/usr/users/myuser/WWW
If you do not have sendmail (yuk!!), then prob better to wrap the above into a script and use logger to send any errors to /var/log/messages, something like :
cron:
#!/bin/bash
if [ -x /usr/local/scripts/rsync-it ]; then
/usr/local/scritps/rsync-it
else
logger -p 'auth.info' "$0: cannot locate|run rsync-it script"
fi
rsync-it script:
#!/usr/bin/env bash
if /usr/bin/rsync -e ssh -avz /home/http/content --exclude "*bak" --exclude "*~" myuser@mysite.com:/usr/users/myuser/WWW; then
logger -p 'auth.info' "$0: successful"
else
logger -p 'auth.info' "$0: ERROR: please check"
fi
Basic idea anyway. Tends to be what I use most of the time. Might be an idea to send it out to a log file as well, as that could be where this is all going wrong.
Cheers,
Last edited by jondkent (2009-04-14 11:26:43)
Offline
Annoying. It is the sendmail issue. I simply did
env VISUAL=nano crontab -e
to edit crontab in nano instead of the stupid vi (read man crontab, it says opens vi by default and otherwise whatever is in VISUAL) and set
05 * * * * /usr/sbin/run-cron /etc/cron.hourly &> /tmp/crond-hourly-results
Hardly elegant, but it works. Thanks for the input.
Offline
@listdata: crond will check both /etc/cron.d and /var/spool/cron for new crontabs. It doesn't need to check the /etc/cron.{hourly,daily,weekly,monthly} directories for new contents because crond itself just calls a script (run-cron or run-parts) that will execute everything it can from those folders when called. So just adding a new executable to those directories should be enough.
Crond sends the outputs of the scheduled job (in your case the output from the shell script) via email to the user which owns the crond process. I believe that it is done via a pipe and even if I'm not entirely sure, that the listening part of the pipe has to be ready before the sendind part is allowed to start.
So if the listening part here is sendmail which isn't configured on your setup as you mentionned, I guess the sending part (your script) is prevented to run by the pipe mechanism, because it would cause a broken pipe.
No, crond collects all the output from a cronjob's stdout and stderr in a temporary file. Only after the cronjob process has exited does crond attempt to mail that to the user, and logs a message if it's unable to. So not having sendmail configured should in no way affect whether the cronjob itself executes successfully.
So androith, if you're finding that your job is working properly now, that's great. But the problem wasn't the sendmail issue. Adding the redirect to your cronline only changed what messages you were getting in your /var/log/crond.log, nothing else. It should make no difference to whether your rsync script executed.
Offline