Question: How to Automatically Run ntpdate When Starting NTPD in CentOS/RHEL 5?
1. By default the file /etc/ntp/step-tickers is empty, to sync the time with ntpdate during the start of ntpd, we need to enter the ip addresses of your time server:
# cat /etc/ntp.conf | grep server server 192.168.X.1 server 192.168.Y.2
# cat /etc/ntp/step-tickers 192.168.X.1 192.168.Y.2
2. Now we can restart the ntp server.
# /etc/init.d/ntpd restart Shutting down ntpd: [ OK ] ntpd: Synchronizing with timer server: [ OK ] Starting ntpd: [ OK ]
ntpd: Synchronizing with timer server: [ OK ], indicates that ntpdate was run during the start of ntpd.
3. When the -x option in /etc/sysconfig/ntpd is used, ntpd will automatically use the time servers configured in /etc/ntp.conf to sync the time when starting even when /etc/ntp/step-tickers is empty.