1

I have a Debian Linux server, recent install. It has this cron job:

7 1 * * *       /do/something/important.sh

As I read that, it should run at 1:07am. Instead, it runs at 5:07pm.

So, wrong timezone, right? No...I'm in US/Pacific and:

# ls -l /etc/localtime
lrwxrwxrwx 1 root root 30 Mar  5 20:29 /etc/localtime -> /usr/share/zoneinfo/US/Pacific
# date
Fri Mar  9 16:54:52 PST 2012

That is the right time as I post this.

Now, cron did run for a couple days with the wrong timezone (default was MST). I fixed that by changing /etc/localtime. I also restarted cron (/etc/init.d/cron restart). I've local-gen'd, too.

That job is running at 17:07 Pacific time consistently...something else I missed?

  • Tough one. Tried reinstating the crontab, yet? i.e. add another cronjob to force it to reload the crontab. – juwi Mar 10 '12 at 1:38
  • Added a date piped to a tempfile to run at 6pm...checked back and it hadn't fired. – raindog308 Mar 10 '12 at 4:05
  • Would've been to simple... Does the user maybe still have a different local timezone? – juwi Mar 10 '12 at 4:16
1

Turns out the answer is:

dpkg-reconfigure tzdata

This is a debian-specific thing. I’m not sure of the fine details of what it does, but it fixed the problem.

This command was formerly tzconfig.

-1

Just restart cron, it will use your local timezone setting. It worked for me.

sudo /etc/init.d/cron restart
  • Based on the question age and the other answer's suggestion of installing a timezone fix do you know when the timezone fix was added to Debian? – Jason Aller Apr 20 '15 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.