Just in time with Linux

Synchronizing the time of your computer is common practice on Linux. However, most distributions tend to use the ntp daemon to synchronize the time of a client. This seems to be a bit much for most systems. On my clients I use ntpdate. ntpdate even works for most servers. If you use Debian, just get it with apt-get.

  1. apt-get install ntpdate

The default is to synchronize the time at system boot. If you use a client that is restarted often enough this works perfectly for you. If you do not restart your client regularly or you run a server that does not need to provide time service to other clients you may as well set up a daily (or even hourly) cron-job.

  1. #!/bin/sh
  2. # /etc/cron.hourly/ntpdate
  3. # launch ntpdate for two servers (in case one fails)
  4. ntpdate ptbtime1.ptb.de
  5. ntpdate ptbtime2.ptb.de

Make your cron-job file executable.

  1. chmod u+x /etc/cron.hourly/ntpdate

That’s it. Now the time will be set to the time of the Physikalisch-Technische Bundesanstalt (Physical Technical Federal Institute), that is responsible for maintaining the correct legal time in Germany. They provide time service for most radio-controlled clocks throughout Germany and Europe, too.

Shameless plug: If this post was useful to you, please consider buying yourself something from one of my Amazon stores: US store, UK store, FR store, DE store, CA store. If you're not into Amazon, why not donate something to GNOME, Mozilla or Wikipedia? Thank you!

Leave a Reply