How to periodically synchronize time in Linux?

  1. Install ntpdate package, unless already installed.
    RedHat Enterprise Linux, CentOS, Oracle Linux:
    # yum install ntpdate
    Debian, Ubuntu:
    # apt-get install ntpdate
    Gentoo:
    # emerge ntp
  2. Create a new file called ntpdate inside /etc/cron.daily with the following contents:
    #!/bin/sh
    /usr/sbin/ntpdate pool.ntp.org 1> /dev/null 2>&1
    
  3. Set the executable bit for the new script: chmod +x /etc/cron.daily/ntpdate
  4. Run /etc/cron.daily/ntpdate to manually synchronize time for the first time.
Advertisements
Posted in Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: