Cron job supposed to run at 23:00, is running at 15:00?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Cron job supposed to run at 23:00, is running at 15:00?
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:
Code:
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:
Code:
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:
Code:
# restart the ImageDaemon each day at 11p PST
0 23 * * * php -q /root/my_script.php > /root/cron_output.txt
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.