Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    2

    Thumbs up Auto update time on Linux (VPS)

    These are my steps that I have been doing to get my Red Hat Linux system clock updated in the crontab with one of the time server using rdate.

    What is rdate?

    man rdate to read more
    rdate connects to an RFC 868 time server over a TCP/IP network, printing the returned time and/or setting the system clock using port 37.

    You can check out the time servers used by the NIST Internet Time Service (ITS) at:
    http://www.boulder.nist.gov/timefreq...e-servers.html
    I will be using time.nist.gov time server as an example in this thread and you are free to use any time server you preferred

    If you have firewall installed, please set to allow port 37 TCP connection.

    Step 1: login to your server via SSH and gain root access.

    Step 2: check whether rdate is installed:

    Code:
    rpm -qa | grep rdateIf it is not install, kindly please install rdate before continue.

    Step 3: add the following in your /etc/crontab file:

    Code:
    # synchronize system time on every 6AM daily with time server
    00 6 * * * root rdate -s time.nist.govYou can do this by cut and paste the following command:

    Code:
    cat >> /etc/crontab << "EOF"
    # synchronize system time on every 6AM daily with time server
    00 6 * * * root rdate -s time.nist.gov && /sbin/hwclock --systohc
    EOFIf you want to update your system & hardware time now, issue the following command in SSH:

    Code:
    rdate -s time.nist.gov
    /sbin/hwclock --systohcHope this helps

    ---------------------
    This is another way of doing it but you can't specify when to synchronize your server/system clock/time though

    Step 1: Gain root access via SSH to your server.

    Step 2: Check whether rdate is installed.

    Code:
    rpm -qa | grep rdateIf rdate is not install, please install it before continue.

    Step 3: Create a shell script, chmod it to executable and place it into /etc/cron.daily directory with the below content.

    Code:
    #!/bin/sh
    rdate -s time.nist.gov
    /sbin/hwclock --systohcFor me, I create /etc/cron.daily/rdate file directly using the following command:

    Code:
    cat > /etc/cron.daily/rdate << "EOF"
    #!/bin/sh
    rdate -s time.nist.gov
    /sbin/hwclock --systohc
    EOF

    chmod +x /etc/cron.daily/rdateHope this helps

  2. #2
    Registered User
    Join Date
    Jan 2014
    Posts
    107
    Thank you for this best tips.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

  Find Web Hosting      
  Shared Web Hosting UNIX & Linux Web Hosting Windows Web Hosting Adult Web Hosting
  ASP ASP.NET Web Hosting Reseller Web Hosting VPS Web Hosting Managed Web Hosting
  Cloud Web Hosting Dedicated Server E-commerce Web Hosting Cheap Web Hosting


Premium Partners:


Visit forums.thewebhostbiz.com: to discuss the web hosting business, buy and sell websites and domain names, and discuss current web hosting tools and software.