Home > System Tutorial > LINUX > body text

Proficient in the configuration and use of ntpd service in Linux

WBOY
Release: 2024-02-09 20:03:13
forward
1034 people have browsed it

Time is of the essence in the computer world, especially in network communications. To ensure that the server and client time are synchronized, the Linux operating system provides an NTP (Network Time Protocol) service to coordinate clock settings. In Linux, the commonly used NTP implementation is ntpd, which is stable and reliable and is widely used.

Proficient in the configuration and use of ntpd service in Linux

In Linux, the commands used to view and set the clock mainly include date, hwclock and clock. Among them, clock and hwclock are similar in usage, except that the clock command not only supports x86 hardware system, but also supports Alpha hardware system. Since most users currently use the x86 hardware system, these two commands can be learned as one command.

1. Use the date command in the virtual terminal to view and set the system time

Operation to view the system clock:

# date
Copy after login

Operation to set the system clock:

# date 091713272003.30
Copy after login

Common setting format:
# date month day hour minute year. second

2. Use the hwclock or clock command to view and set the hardware clock

View the operation of hardware clock:

# hwclock --show 或
# clock --show
2003年09月17日 星期三 13时24分11秒 -0.482735 seconds
Copy after login

Operation to set the hardware clock:

# hwclock --set --date="09/17/2003 13:26:00"
或者
# clock --set --date="09/17/2003 13:26:00"
Copy after login

Common setting format: hwclock/clock –set –date="month/day/year hour: minute: second".

3. Synchronize system clock and hardware clock

Linux system (the author is using Red Hat 8.0, and has not done experiments on other systems) by default, after restarting, the hardware clock and system clock are synchronized. If it is not convenient to restart (servers usually rarely restart), use the clock or hwclock command to synchronize the system clock and hardware clock.
Synchronize the hardware clock with the system clock:

# hwclock --hctosys
或者
# clock --hctosys
上面命令中,--hctosys表示Hardware Clock to SYStem clock。
Copy after login

System clock and hardware clock synchronization:

# hwclock --systohc
或者
# clock --systohc
Copy after login

2. We now need to synchronize the LINUX server with a time synchronization server on the network. The operation process is as follows:

ntpdate 210.72.145.44
Copy after login

When executing the synchronization time command prompt: the NTP socket is in use, exiting, you need to stop the time service (/etc/init.d/ntpd stop) before executing the synchronization time command

Approximately usable NTP time server address in China

server 133.100.11.8 prefer
server 210.72.145.44
server 203.117.180.36
server 131.107.1.10
server time.asia.apple.com
server 64.236.96.53
server 130.149.17.21
server 66.92.68.246
server www.freebsd.org
server 18.145.0.30
server clock.via.net
server 137.92.140.80
server 133.100.9.2
server 128.118.46.3
server ntp.nasa.gov
server 129.7.1.66
server ntp-sop.inria.frserver 210.72.145.44(中国国家授时中心服务器IP地址)
server ntp.sjtu.edu.cn(上海交通大学网络中心NTP服务器地址)
Copy after login

=================================

NTP addresses of other universities: Server list:

s1a.time.edu.cn 北京邮电大学 010
s1b.time.edu.cn 清华大学 010-62795818-6105
s1c.time.edu.cn 北京大学 010-62753007
s1d.time.edu.cn 东南大学 025-3794342-309
s1e.time.edu.cn 清华大学 010-62795818-6105
s2a.time.edu.cn 清华大学 010-62795818-6105
s2b.time.edu.cn 清华大学 010-62795818-6105
s2c.time.edu.cn 北京邮电大学 010-62283044-8003
s2d.time.edu.cn 西南地区网络中心
s2e.time.edu.cn 西北地区网络中心 029-2669037
s2f.time.edu.cn 东北地区网络中心 024-23966854
s2g.time.edu.cn 华东南地区网络中心 021-62932901-8101
s2h.time.edu.cn 四川大学网络管理中心 028-85414820
s2j.time.edu.cn 大连理工大学网络中心 0411-4708642
s2k.time.edu.cn CERNET桂林主节点 0773-5845246
s2m.time.edu.cn 北京大学
time.jmu.edu.cn
Copy after login

In short, the ntpd service, as a commonly used NTP implementation in Linux, can keep the server and client clock synchronized, thereby improving the performance and reliability of the entire system. Through this article, we learned how to configure and use the ntpd service in a Linux system, and how to solve some common problems. In future work, we can configure and optimize the ntpd service more according to actual needs to meet different application scenarios.

The above is the detailed content of Proficient in the configuration and use of ntpd service in Linux. For more information, please follow other related articles on the PHP Chinese website!

source:lxlinux.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!