Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 01-15-2012, 06:32 PM   #1
Senior Member
Registered: Dec 2004
Posts: 1,025

Rep: Reputation: 67
Cron job supposed to run at 23:00, is running at 15:00?

I've allocated a Cloud Server running Ubuntu at The server was initially configured to be on UTC time. As I live in Los Angeles, this was a bit maddening when trying to determine what times cron jobs should run (this machine cooperates with another server in the United States). I therefore went through the trouble of changing the time on the server by doing this:
apt-get install ntp
dpkg-reconfigure tzdata  // this launches a wizard
Now, when I type the date command on my server via ssh, it reflects the same time and timezone as my ubuntu desktop here in los angeles:
root@server:~# date
Sun Jan 15 16:29:20 PST 2012
The problem is that I have a cron job set up to run at 23:00 hours (11pm) but it is running at 15:00 hours los angeles time. Unless I'm mistaken, that's equal to 23:00 UTC, right? Seems to me that somehow the cron jobs are unaffected by my date changes above and for some reason the times I specify in my crontab are still in UTC. WTF? How do I fix this?

Here's the crontab. This script fired off at 3pm california time today:
# restart the ImageDaemon each day at 11p PST
0 23 * * * php -q /root/my_script.php > /root/cron_output.txt
Old 01-15-2012, 08:18 PM   #2
Senior Member
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Wheezy/Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,613

Rep: Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691Reputation: 691
As it seems, this is not the system wide /etc/crontab but the user crontab, right? Since after editing this crontab I always get that message "installing new contab" it could be that something funny happened and you have to edit and save your file again with crontab -e.

However, I recommend to run your servers in UTC. I am running several servers in different places in the world, and I run them all in UTC. My desktops as well, and I only change the clock display on my desktop. The machine is in UTC.

I make regular mistakes, granted. But once I hit the wall again after such a mistake, it never, ever goes wrong regarding cron jobs, file synchronization, mail time stamps, whatever. I know it is awkward to calculate times back from UTC to local, especially when a date change is involved, but still at the end you see less mistakes. I am UTC-4, not as bad as UTC-7, still happy with this policy I choose a several years ago.

Old 01-15-2012, 11:55 PM   #3
Valery Reznic
ELF Statifier author
Registered: Oct 2007
Posts: 676

Rep: Reputation: 136Reputation: 136
I think that happened following.
You said, that server was initially configured to use UTC. So when cron started time-zone was UTC.

Now, you reconfigured time-zone, and date command from the terminal uses and shows correct time-zone.

But cron still uses time-zone that was set on his start up.

So, re-starting cron should solve the problem.
1 members found this post helpful.
Old 01-17-2012, 12:50 PM   #4
Senior Member
Registered: Dec 2004
Posts: 1,025

Original Poster
Rep: Reputation: 67
Restarting cron appears to have solved the problem:
sudo service cron restart
1 members found this post helpful.
Old 04-19-2012, 12:36 PM   #5
LQ Newbie
Registered: Dec 2006
Location: Los Angeles
Distribution: Debian/Ubuntu/CentOS
Posts: 11

Rep: Reputation: 0
I'm having the same issue but with Amazon EC2 running Debian 6. I had previous scripts that worked on Debian 5 to the new box but they run at the wrong times. I set the server to be in the CST time zone by using dpkg-reconfigure tzdata. I checked under /etc/default/cron but there isn't any TZ syntax in there to specify the zone.

Is there any way to check if the cron is running on UTC? I rebooted the server and also restarted the cron service (/etc/init.d/cron restart) as well. Should I set the server back to UTC zone or run it with the specific time zone (CST)? I ran debian 5 and never had this issue, something must of changed in 6 that I'm not aware of.


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
Run cron job in every 20 second ust Linux - Newbie 13 01-15-2015 01:01 PM
Can't get a cron job to run derzok Linux - General 10 12-16-2007 04:00 AM
how to run this cron job ashley75 Linux - General 5 05-24-2004 11:20 AM
Did my Cron job run? ryedunn Linux - Newbie 2 02-25-2004 08:59 AM
Cron job does not run brentos Linux - General 6 12-12-2003 02:37 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:18 PM.

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