Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I noticed that the backupscript I placed in /etc/cron.weekly on my Debian6 server isn't executed I placed this small script in it, to see if the weekly cronjob is executed at all:

#!/bin/bash
echo 'CRON RAN' > /var/log/cron-weekly-runcheck.log

saved it as

-rwxr-xr-x 1 root root 64 Jul 15 02:14 /etc/cron.weekly/runcheck.sh

When I checked today, the logfile it was supposed to create did not exist.
The crontab looks like the following (which should be the default debian6 crontab to my knowledge):

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 1   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

Everything that shows up of the weekly cronjob in any logfiles is this line:

Jul 16 06:47:01 wtwrp /USR/SBIN/CRON[29272]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ))

Side note: cron.daily seems to work since logrotate works. cron.hourly has no scripts in it.

Any ideas on what could possibly be going wrong?

share|improve this question
    
Check root's mail for output and potentially error messages. Can be found in /var/spool/mail/root if you don't already have /etc/aliases set up to forward root's mail somewhere it can be read. –  Ladadadada Jul 16 '12 at 11:23
    
@Ladadadada good idea! Unfortunately there is absolutely nothing concerning cron.weekly in there. –  Cobra_Fast Jul 16 '12 at 11:26

2 Answers 2

up vote 6 down vote accepted

The cron.weekly scripts are started by run-parts which skips all files with extension. Rename runcheck.sh to runcheck and it should do

share|improve this answer
3  
That's the kind of thing you only get caught out by once I'll bet. –  Iain Jul 16 '12 at 11:41

comm1 || comm2 || comm3 || comm4

will be executed until first retval = 0 will be returned (from left to right). The rest of chained commands are optimized by interpreter and NOT executed at all

If test -x /usr/sbin/anacron return zero as retval, no other commands will be executed.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.