I've allocated a Cloud Server running Ubuntu at rackspace.com. 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
    sneakyimp;10994557 wrote:

    As I live in Los Angeles, this was a bit maddening when trying to determine what times cron jobs should run

    Isn't that the whole point of using UTC?

    You've got a developer in London working on a server in Los Angeles designing a web app for users in Chicago and Miami that interacts with a server in Tokyo. Now, what time zone would it make sense to use?

    To me, the answer would be UTC (the 'U' stands for universal, after all).

      I appreciate the advice, but I think in this situation (which involves other people) that changing the time zone is the right thing to do. As it turns out, restarting the cron service appears to have solved the problem:

      sudo service cron restart

        You know i was thinking "I bet its because you created the cron job before resetting the timezone" Appears you figured that out tho.

          Derokorian;10994735 wrote:

          You know i was thinking "I bet its because you created the cron job before resetting the timezone" Appears you figured that out tho.

          Strictly speaking that isn't exactly the case. I tried editing my cronjob and saving it again so that the cron job was "re-installed" or whatever but this didn't solve the problem. The issue is that the cron service reads the system time/timezone settings when its starts. If you change the time or timezone, the cron service will not be aware that the server's time/timezone has changed. You have to restart the cron service so that it re-loads the time/timezone settings.

            Oh... well still I wish I had a clue when it came to linux... Strictly speaking - I fail at linux!

              Write a Reply...