Table of Contents

Linux Commands Cheat Sheet

How to use ntpdate command in Linux (with example)



ntpdate options

# man ntpdate

COMMAND LINE OPTIONS

       -B      Force  the  time to always be slewed using the adjtime() system call, even if the measured
               offset is greater than +-500 ms. The default is to step the time using  settimeofday()  if
               the  offset  is greater than +-500 ms. Note that, if the offset is much greater than +-500
               ms in this case, that it can take a long time (hours) to slew the  clock  to  the  correct
               value. During this time. the host should not be used to synchronize clients.

       -b      Force  the  time  to  be  stepped using the settimeofday() system call, rather than slewed
               (default) using the adjtime() system call. This option should be used when called  from  a
               startup file at boot time.

       -u      Direct  ntpdate to use an unprivileged port for outgoing packets. This is most useful when
               behind a firewall that blocks incoming traffic to privileged ports, and you want  to  syn‐
               chronize  with hosts beyond the firewall. Note that the -d option always uses unprivileged
               ports.


Examples

RHEL6/CentOS6

# ntpdate -Buv xx.xx.xx.xx
# /etc/init.d/ntpd stop
# ntpdate -b -f xx.xx.xx.xx
# /etc/init.d/ntpd start

RHEL7/CentOS7

# systemctl stop chronyd
# ntpdate -b -f xx.xx.xx.xx
# systemctl start chronyd



Linux Commands Cheat Sheet