1

I've a Ruby file which executing creates and XML file and saves it. Every time it does it the time for the file (last modification) is incorrect (1 hour ahead). I also noticed that cron jobs execute 1 hour later than then should.

When calling date and hwclock in command line I see correct time. How to fix it?

2
  • 2
    Has daylight saving time perhaps begun or ended (whatever it is, I just know the clocks get messed with!) in your country? Is your default system-wide timezone UTC, which doesn't care about such things?
    – voretaq7
    Sep 8, 2011 at 22:23
  • for time/zone-debugging also see bbs.archlinux.org/viewtopic.php?id=167407 (Timezone set correct, yet time wrong (Europe/Belfast))
    – MacMartin
    Oct 17, 2019 at 11:45

2 Answers 2

3

This is not a clock problem but a time zone problem. For this you have to understand the difference between UTC and local time.

So probably your Ruby script is not able to see the difference or misinterprets the global time zone setting. But to make sure you have to give way more information. So for example if the clock is set to UTC or local time? what is your local time zone or offset to UTC? Which Linux distribution do you use? Read how to configure time zones in your specific Linux distribution.

2
  • Linux Debian Lenny. But will it fix cron tasks being executed 1 hour late too?
    – Rihards
    Sep 8, 2011 at 22:33
  • Then read this wiki.debian.org/TimeZoneChanges. In the past one of my Etch boxes was broken in time zone configuration. I had to reinstall tzdata package and had to copy a new zone over /etc/localtime to get it fixed. So read, check, fix and see what remains broken.
    – mailq
    Sep 8, 2011 at 22:44
2

I recently had a similar problem on a Debian Lenny box that was set to UTC when I wanted localtime.

First you need to copy (or symlink) your correct zoneinfo file from /usr/share/zoneinfo to /etc/localtime. For example I ran ln -s -f /usr/share/zoneinfo/America/Los_Angeles /etc/localtime on my system.

Second you need to edit /etc/timezone to reflect your timezone as well. On my system, the file states America/Los_Angeles.

Once both of those files are taken care of, it is a good idea to restart crond to ensure the proper timezone is picked up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .