-   Linux - General (
-   -   Debian daily cron job won't run, but does run in cron.hourly. (

sandersch 05-21-2012 06:24 AM

Debian daily cron job won't run, but does run in cron.hourly.
I have made a bash backup script that should run daily. I put it in "/etc/cron.daily/" and named it "backup". It has the same permissions as the other working scripts in cron.daily.
The cron daemon has been restarted as a precaution.
If I move the same script to "/etc/cron.hourly" it does run.
What could be wrong?

blue_print 05-21-2012 10:03 AM

Did you check the /var/log/cron regarding your cronjob? The log file will give you the detail if any issues.

sandersch 05-21-2012 10:13 AM

Yes, but I just turned it on today.
I only see that the hourly cron has run like:
May 21 16:12:01 host /USR/SBIN/CRON[15580]: (root) CMD (cd / && run-parts --report /etc/cron.hourly)

dru8274 05-21-2012 07:03 PM

I once had a similar problem. My logrotate cronjob didn't run, unless I had my computer turned on at a certain time, late at night. But it worked better after I installed anacron.

sandersch 05-22-2012 04:04 AM

Hello dru8274

Anacron is installed and it work better for computers that aren't on all the time. My problem exist on a server that is on all the time.
The cron job is run as you can see below, but the backup script in /etc/cron.daily/ isn't run. Nothing further is reported neither.

May 22 03:56:01 host /USR/SBIN/CRON[21945]: (root) CMD (test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ))

dru8274 05-23-2012 08:58 PM

Well, your problem isn't obvious. Cron can be fussy about which files it runs. Your backup script may need to be executable, and owned by root. And cron can also be fussy about filenames to - it may only accept filenames that contain a limited range of characters. An excerpt here from the cron manpage (from debian)...

"the files under these directories have to be pass some sanity checks including the following: be executable, be owned by root, not be writable by group or other and, if symlinks, point to files owned by root. Additionally, the file names must conform to the filename requirements of run-parts: they must be entirely made up of letters, digits and can only contain the special signs underscores ('_') and hyphens ('-')."

sandersch 05-24-2012 02:33 AM

It does match all those requirements.
The weird thing is it runs perfectly in /etc/cron.hourly
This is driving me mad :-(

Could it need any special requirements in the file?
Like an enviroment variable.

lithos 05-24-2012 02:50 AM


I don't know Deb, but in RHEL/CentOS there are 2 crontab's
- one is: /etc/crontab


# Run-parts
01 * * * * run-parts /etc/cron.hourly
02 4 * * * run-parts /etc/cron.daily
22 4 * * 0 run-parts /etc/cron.weekly
42 4 1 * * run-parts /etc/cron.monthly

This runs all the "hourly", "daily" ... jobs

- which are located in "/etc/cron.hourly", "/etc/cron.daily" , etc...

total 44
drwxr-xr-x  2 root root 4096 May 24 04:02 ./
drwxr-xr-x  58 root root 4096 May 23 15:30 ../
-rwxr-xr-x  1 root root  66 Feb 26  2007 amavisd*
-rwxr-xr-x  1 root root  81 May  9  2011 apf*
-rw-r--r--  1 root root  436 Sep 21  2010 freshclam
-rwxr-xr-x  1 root root  180 Feb 26  2007 logrotate*
-rwxr-xr-x  1 root root  220 May  2  2007 logwatch-cron*
-rwxr-xr-x  1 root root  402 Feb 26  2007 makewhatis.cron*
lrwxrwxrwx  1 root root  31 May 24 04:02 refresh.apf -> /etc/apf/internals/cron.refresh
-rwxr-xr-x  1 root root  104 Feb 26  2007 rpm*
-rwxr-xr-x  1 root root  142 Feb 26  2007 slocate*
-rwxr-xr-x  1 root root  138 Feb 26  2007 tmpwatch*

So it might be that the first "/etc/crontab" is not running "daily" jobs ?

All times are GMT -5. The time now is 06:55 AM.