Two methods of time synchronization under linux

Method 1:

Synchronize with a known time server

ntpdate time.nist.gov


where time.nist.gov is a time server.
Delete the local time and set the time zone to Shanghai

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


Method 2:
linux automatically synchronizes time
vi /etc/crontab
with a sentence:
00 0 1 * * root rdate -s time.nist.gov


Time server configuration (192.168.10.1)

1)、# rpm -ivh ntp-4.1.2-4.EL3.1.i386.rpm
2 、 、 # vi /etc/ntp.conf


Comment a line:
restrict default ignore
Add a line:

restrict 192.168.10.0 mask 255.255.255.0 notrust nomodify notrap


3), # vi /etc/ntp/step-tickers
add a line:
pool.ntp.org
so that every time ntpd starts, it will automatically connect to the international standard time server;
4), # service ntpd start
5), # netstat - an |grep 123
make sure the port is open in udp
time client configuration (192.168.10.2)
1), #ntpdate 192.168.10.2
should show successful synchronization
2), #crond -e
join
0-59/10 * * * * /usr/sbin/ntpdate 192.168.10.1


Synchronize time every 10 minutes

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326925893&siteId=291194637