Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
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 '11 at 22:23
add comment

2 Answers

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.

share|improve this answer
    
Linux Debian Lenny. But will it fix cron tasks being executed 1 hour late too? –  Richards Sep 8 '11 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 '11 at 22:44
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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