Jump to Navigation

107 - NTP Server Configuration

The NTP server (ntpd) can be setup to run continuously. This will keep the system clock synchronized.
You will also be able to server NTP clients on your LAN, if you wish. 

1. Edit /etc/ntp.conf

-------------------------
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

server 127.127.1.0   # local clock
fudge  127.127.1.0 stratum 10
--------------------------------

2. Start NTP Server

After you install this new version of the config file, you can start the service with /etc/init.d/ntpd start.

# /etc/init.d/ntpd start

3.Check NTP Server Status.

To monitor the service, you can run the following command:

# ntpdc -p  (or ntpdc -p -n, ntpq -p)

4.checkconfig

If you want to have the NTP server start up automatically, you can use the checkconfig command
as follows:

# chkconfig --level 345 ntpd on
# chkconfig --level 0126 ntpd off
# chkconfig --list | grep ntpd
ntpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off

5.Port Status

To see that your NTP server is listening on UDP port 123, use the following command: 

# netstat -tuna

6. Set time manually

# /etc/init.d/ntpd stop
# ntpdate -b -v mytimeserver.com

# hwclock --systohc --utc

 7. Update

$ /usr/sbin/ntpdate -q 0.rhel.pool.ntp.org  #check accessible

$ /usr/sbin/ntpdate -s 0.rhel.pool.ntp.org

If you want to update the time right now, you can stop the NTP service and then run the following command,
swapping out your preferred server for 0.rhel.pool.ntp.org.

 8. crontab sample for update time

# Daily time update at 1:23AM
23 1 * * * ntpdate -s server1 [server2 ...

 

 

 

 

 



Main menu 2

Story | by Dr. Radut