LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 02-15-2012, 02:42 AM   #1
shoutr
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Rep: Reputation: Disabled
crontab doesn't execute the jobs at the right time


Hello,

I'm battling with this strange problem for a while now:
i run a local server under ubuntu 11.04, it's used as a web server for various items registered in a database. And i want to save this database each hour of the working day.
So i made a script containing a mysqldump, and i use cron to run this script with the following line:

00 8-18 * * * root /etc/init.d/sql-backup-hourly.sh >> /tmp/script-sql-backup-hourly.txt

now the weird thing: the server starts the script at 10 instead of 8 (and after 10 it works perfectly)
I've tried numerous ways to do the job: the original one was in crontab -e using VI, then using gedit to edit the/etc/crontab file. Both did the same thing.
I tried a different way to specify the minutes:

01 8-18 * * * or 0 8-18 * * *

none of them worked.
the server is at the right time and date and timezone, so are the only 2 users created on it (root and user).

I've tried this on another ubuntu 11.04 and the same problem arose.

Halp \o/
 
Old 02-15-2012, 03:24 AM   #2
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,669

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
If you put "nice" to 1 it doesn't run on time?
 
Old 02-15-2012, 03:57 AM   #3
shoutr
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
no, still doesn't starts on time :/ (and now the server doesn't seems to execute the cron at all.

i think i'll try to turn around this problem and put this script in the /etc/cron.hourly/ and make it execute each hour
 
Old 02-15-2012, 04:11 AM   #4
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,669

Rep: Reputation: 498Reputation: 498Reputation: 498Reputation: 498Reputation: 498
Yes I did my back up scripts inside the /etc/cron.weekly directory and I have no problem with it. Just as usual chmod +x you know that of course.

BTW, have you examined the hardware time (clock) if it matches with the kernel time? Try check "hwclock".

Goodluck.
 
Old 02-16-2012, 02:16 AM   #5
shoutr
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
the hwclock runs on CET time (i'm on gmt+1) it's exactly one hour earlier than system time. but if it was related to that, all the backups would have a one hour delay, it's not the case here, it's starts running at 10 instead of 8, but stops at the right time (18).

trying the run-parts now, with the script put into /etc/cron.hourly.
the script is launched nicelly at whatever hour i want, but for whatever reason i don't get, it's the mysqldump line in the script that can only be run starting at 10.

here the msqldump line:
mysqldump -uroot -ppassword --opt --all-databases > alldatadases_`date +"%k%M"`.sql

could be related to the %k%M part then
 
Old 02-16-2012, 02:23 AM   #6
shoutr
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
same problem as here then: http://www.linuxquestions.org/questi...lename-276505/
 
  


Reply



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
How can I tell if crontab jobs are axecuting ? juanb Linux - General 4 01-27-2011 09:08 AM
crontab doesn't execute python script right msegmx Linux - Newbie 13 05-04-2009 09:29 AM
Script doesn't execute in crontab jis0501 Linux - General 2 08-04-2007 07:09 AM
Crontab not running jobs ncracraf Linux - Newbie 6 09-02-2006 02:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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
Open Source Consulting | Domain Registration