Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize time synchronization in linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, Xiaobian will bring you about how to achieve time synchronization in Linux. The article is rich in content and analyzes and narrates from a professional perspective. After reading this article, I hope you can gain something.

Method 1:

Synchronizing with a known time server

The code is as follows:

ntpdate time.nist.gov

Where time.nist.gov is a time server.

Delete local time and set time zone to Shanghai

The code is as follows:

rm -rf /etc/localtime

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

Method 2:

Linux automatic synchronization time

vi /etc/crontab

Add:

The code is as follows:

00 0 1 * * root rdate -s time.nist.gov

Configuration Time Server Configuration (192.168.10.1)

The code is as follows:

1)、# rpm -ivh ntp-4.1.2-4.EL3.1.i386.rpm

2)、# vi /etc/ntp.conf

One line of comment:

restrict default ignore

Insert a line:

The code is as follows:

restrict 192.168.10.0 mask 255.255.255.0 notrust nomodify notrap

3)、# vi /etc/ntp/step-tickers

Insert a line:

pool.ntp.org

This way, 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 mode

Time Client Configuration (192.168.10.2)

1)、# ntpdate 192.168.10.2

Should show synchronization success

2)、# crond -e

join

The code is as follows:

0-59/10 * * * * /usr/sbin/ntpdate 192.168.10.1

Time synchronization every 10 minutes

The above is how to achieve time synchronization in Linux shared by Xiaobian. If there is a similar doubt, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report