LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-26-2013, 01:14 AM   #1
Lenf2
LQ Newbie
 
Registered: Mar 2013
Posts: 4

Rep: Reputation: Disabled
Question Why is cron 4 hours late?


Hi.

I've got a bunch of linux servers, hosted on Amazon Web Services. Most are Amazon Linux, but two are RHEL 5. On all servers, in my /etc/cron.d directory, I have a cron file that invokes a custom Java tool to back up the virtual hard disks. All servers' cron scripts are supposed to run at midnight.

Looking at the timestamps on the virtual hard disk backups, I can see the Amazon Linux ones are indeed created at midnight UTC. However, the RHEL 5 ones are late. Today's backup is exactly 4 hours late, for both RHEL 5 servers. Yesterday it was 4:47 late, again for both servers. So cron is definitely getting invoked, and the backups are getting carried out, but not when I scheduled them.

On my RHEL 5 server, /var/log/cron does indeed have entries timestamped midnight. If I do "date -u" it shows the same time as the Amazon Linux servers.

What's going on here? How else can I debug this?
 
Old 03-26-2013, 01:17 AM   #2
Lenf2
LQ Newbie
 
Registered: Mar 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
NM, looks like I have the wrong timezone set on the RHEL servers...
 
Old 03-26-2013, 01:25 AM   #3
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Command "date -u" will show you time in UTC i.e. Universal time, whereas command "date" will show you time according to timezone configured in the server. However, as far as I am concered, cron will run according to time shown in "date" command, not according to "date -u" command.
Code:
~$ date
~$ date -u
So either modify your cron entry according to output of "date" command or modify server's timezone.
 
Old 03-27-2013, 12:34 AM   #4
Lenf2
LQ Newbie
 
Registered: Mar 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yeah, I realised timezone must have been the problem. It looks like I'm still doing something wrong, though, because cron's still doing its thing four hours late.

The "date" command is saying it's in UTC, and the time it produces is correct. The last backups were still at 04:00 UTC.

...I guess I'll restart cron and see if that works. I'm using "sudo /sbin/service crond restart", for reference.
 
Old 03-27-2013, 06:25 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,166

Rep: Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751Reputation: 751
Check /etc/crontab to see what time /etc/cron.daily is run at, by default on RHEL it runs at 4:02am


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

Last edited by TenTenths; 03-27-2013 at 06:27 AM.
 
Old 03-27-2013, 08:20 PM   #6
Lenf2
LQ Newbie
 
Registered: Mar 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Restarting crond did it!
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job running 12 hours off hattori.hanzo Linux - Newbie 4 04-07-2009 02:50 AM
Clock two hours late on debian sarajevo Linux - Server 4 10-17-2007 11:58 AM
Cron running 4 hours late ResOrb Slackware 2 06-15-2007 08:45 AM
Calling a Php file from CRON every hours ? airbuzz *BSD 10 02-03-2004 03:04 PM
Cron/Vixie runs jobrotate 6 hours late SEL Linux - General 0 04-21-2002 05:56 AM


All times are GMT -5. The time now is 01:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration