• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • How to forcefully sync date and time using the NTP server in Linux

    The commands and steps to initiate a forceful sync with NTP server may vary based on the distribution you are using.

    By default if NTP service is running it will automatically sync the client's date and time from the NTP server based on the polling interval but what if you want to do a force sync immediately and cannot wait for the NTP client to sync it.



    On SuSE Enterprise Linux

    The current date and time on my node is
    # date
    Fri Dec  8 02:51:04 IST 2017

    My ntp service status
    # /etc/init.d/ntp status
         remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
     192.168.10.100    10.171.8.4       3 u    1   64    1    0.173  -593996   0.000
     10.40.130.1     .INIT.          16 u    -   64    0    0.000    0.000   0.000

    Checking for network time protocol daemon (NTPD):                       running

    So my ntp client is running, lets change the date and time of my node before doing a force sync
    # date --set "4 Dec 2017 10:00:00"
    Mon Dec  4 10:00:00 IST 2017

    My new date and time
    # date
    Mon Dec  4 10:00:02 IST 2017

    Time to do a force sync





    # /etc/init.d/ntp ntptimeset
    Time synchronized with 192.168.10.100

    So as you see it immediately sent a request to the NTP server and updated the localhost date and time details from the NTP server
    # date
    Thu Dec  7 10:23:35 IST 2017


    On Red Hat Enterprise Linux 7

    Unfortunately ntptimeset is not available in Red Hat Enterprise Linux so we have to try something else

    My existing date and time
    # date
    Thu Dec  7 10:25:03 IST 2017

    NTPD service status
    # systemctl status ntpd
    ● ntpd.service - Network Time Service
       Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
       Active:
    active (running) since Wed 2017-12-06 17:43:02 IST; 16h ago
      Process: 5957 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
     Main PID: 5958 (ntpd)
       CGroup: /system.slice/ntpd.service
               └─5958 /usr/sbin/ntpd -u ntp:ntp -g

    Dec 06 17:43:02 Ban17-pgw01-a systemd[1]: Starting Network Time Service...
    Dec 06 17:43:02 Ban17-pgw01-a ntpd[5957]: ntpd 4.2.6p5@1.2349-o Wed Mar  1 09:00:51 UTC 2017 (1)
    Dec 06 17:43:02 Ban17-pgw01-a systemd[1]: Started Network Time Service.
    Dec 06 17:43:02 Ban17-pgw01-a ntpd[5958]: proto: precision = 0.038 usec
    Dec 06 17:43:02 Ban17-pgw01-a ntpd[5958]: 0.0.0.0 c01d 0d kern kernel time sync enabled

    Now lets change the date and time
    # date --set "4 Dec 2017 10:00:00"
    Mon Dec  4 10:00:00 IST 2017

    First stop the ntpd service
    # systemctl stop ntpd
    Next initiate a force sync from your NTP server using the below command
    # ntpdate 192.168.10.100
     7 Dec 10:27:36 ntpdate[6701]: step time server 192.168.10.100 offset 260769.003401 sec

    Now start the NTP service again
    # systemctl start ntpd
    Lastly validate if your localhost date and time is updated correctly
    # date
    Thu Dec  7 10:27:48 IST 2017



    Follow the below links for more tutorials

    How to find the path of any command in Linux
    How to configure a Clustered Samba share using ctdb in Red Hat Cluster
    How to delete an iscsi-target from openfiler and Linux
    How to perform a local ssh port forwarding in Linux
    How to use yum locally without internet connection using cache?
    What is umask and how to change the default value permanently?
    Understanding Partition Scheme MBR vs GPT
    How does a successful or failed login process works in Linux
    How to find all the process accessing a file in Linux
    How to exclude multiple directories from du command in Linux
    How to configure autofs in Linux and what are its advantages?
    How to resize software raid partition in Linux
    How to configure Software RAID 1 mirroring in Linux
    How to prevent a command from getting stored in history in Linux

    Deepak Prasad

    Deepak Prasad is an anonymous techie and an author who is still trying to survive in this IT generation with very little knowledge he has on Linux/Unix, VMware, SAN Storage, Automation, networking etc

    You can follow him on Facebook or Google+

    Do you also have something to share here?

    Become an author and be a part of our GoLinuxHub Team, Click here for more information
    How to forcefully sync date and time using the NTP server in Linux How to forcefully sync date and time using the NTP server in Linux Reviewed by Deepak Prasad on Friday, December 08, 2017 Rating: 5

    No comments:

    Powered by Blogger.