Aug 07

I had to do this many times, but still not enough to stick to my head, so I always end up googling for it. I decided to Blog it now finally, so I will always have this information handly, and hope to help others too.

My Distribution is Debian Linux, but I assume it will work on others too.

To set your time-zone, do the following:


ln -sf /usr/share/zoneinfo/Europe/Budapest /etc/localtime

that is if your time zone is Budapest. Just browse the /usr/share/zoneinfo/ folder and see which location matches you.
When that is done, you need to adjust your time. Lately on systems that have internet connectivity, I just use a Time Server which keeps my time updated hourly, as I set a Cron job to do so.

To get this done, I install “ntpdate”


apt-get install ntpdate

Now I set cron to run the job hourly, but you can set whatever timeframe you want:


crontab -e

Here I added the following line:


#Setup NTPDATE
@hourly /etc/network/if-up.d/ntpdate

then restarted cron


/etc/init.d/cron restart

and that was it. Our hourly automatic time update is set. Now to test if all went well, I manually updated the time:


/etc/network/if-up.d/ntpdate

and checked if it was okay. If you see the right timezone and right time, just save it to the BIOS clock as well so even offline the time will remain correct more or less:


/sbin/hwclock --systohc

and we are done. Enjoy having a Linux box with never failing correct time!

One Response to “How to set Time and Date plus Timezone in Linux”

  1. ppp Says:

    how can find my traffic fine

Leave a Reply