LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 05-21-2012, 06:24 AM   #1
sandersch
LQ Newbie
 
Registered: May 2012
Location: Netherlands
Distribution: CentOS/RHEL, Debian, Ubuntu, CrunchBang #!
Posts: 8

Rep: Reputation: Disabled
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?
 
Old 05-21-2012, 10:03 AM   #2
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 49
Did you check the /var/log/cron regarding your cronjob? The log file will give you the detail if any issues.
 
Old 05-21-2012, 10:13 AM   #3
sandersch
LQ Newbie
 
Registered: May 2012
Location: Netherlands
Distribution: CentOS/RHEL, Debian, Ubuntu, CrunchBang #!
Posts: 8

Original Poster
Rep: Reputation: Disabled
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)
 
Old 05-21-2012, 07:03 PM   #4
dru8274
Member
 
Registered: Oct 2011
Location: New Zealand
Distribution: Debian
Posts: 105

Rep: Reputation: 36
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.
 
Old 05-22-2012, 04:04 AM   #5
sandersch
LQ Newbie
 
Registered: May 2012
Location: Netherlands
Distribution: CentOS/RHEL, Debian, Ubuntu, CrunchBang #!
Posts: 8

Original Poster
Rep: Reputation: Disabled
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 ))
 
Old 05-23-2012, 08:58 PM   #6
dru8274
Member
 
Registered: Oct 2011
Location: New Zealand
Distribution: Debian
Posts: 105

Rep: Reputation: 36
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 ('-')."
 
Old 05-24-2012, 02:33 AM   #7
sandersch
LQ Newbie
 
Registered: May 2012
Location: Netherlands
Distribution: CentOS/RHEL, Debian, Ubuntu, CrunchBang #!
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
 
Old 05-24-2012, 02:50 AM   #8
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi,

I don't know Deb, but in RHEL/CentOS there are 2 crontab's
- one is: /etc/crontab
Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin

# 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...
Code:
cron.daily#>ls
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 ?
 
  


Reply

Tags
bash, cron, debian


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cron JOB won't run - Slackware 12.1 ovidiu84 Linux - Newbie 10 06-15-2011 09:35 AM
[SOLVED] BASH: Add cron job to run hourly worm5252 Programming 9 03-26-2010 11:36 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 09:26 PM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 07:37 PM


All times are GMT -5. The time now is 05:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration