Due to hardware reasons, the machines may not keep up with the standard time to a certain extent, with the error ranging from a few seconds to a few minutes in a month. If the server time is inaccurate, it will cause a lot of trouble. For example, when making a payment, you are unable to place an order or the game cannot be logged in. Method 1: Use ntpdate to update the time from the time server If the system does not have the ntpdate command, you can install it online: yum -y install ntp After installation, you don’t need to do any configuration, just test it directly [root@snsgou-pc src]# date Wednesday, May 20, 2015 22:42:19 CST [root@snsgou-pc src]# ntpdate time.nist.gov 20 May 22:42:38 ntpdate[26759]: step time server 131.107.13.100 offset 2.117558 sec [root@snsgou-pc src]# date Wednesday, May 20, 2015 22:43:17 CST The above situation indicates that the network time synchronization is successful. We can use scheduled tasks to synchronize time regularly Use the crontab -e command to enter the crontab editing state and append the following scheduled task text */10 * * * * ntpdate time.nist.gov #domain name or IP Indicates synchronization every ten minutes. Recommended time servers: time.nist.gov time.nuri.net 0.asia.pool.ntp.org 1.asia.pool.ntp.org 2.asia.pool.ntp.org 3.asia.pool.ntp.org Method 2: Use ntp to build your own time server When we build our own time server, we don't need crontab to run it regularly. 1. Install the time server ntp yum install ntp 2. Configure ntp [root@localhost ~]# cat /etc/ntp.conf |awk '{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}' restrict default ignore //By default, modification or query of ntp is not allowed, and special packets are not received restrict 127.0.0.1 //Give all permissions to the local machine restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify //Give the LAN machine the permission to synchronize time server time.nist.gov prefer //Set the time server, add prefer to indicate priority server 0.asia.pool.ntp.org server 1.asia.pool.ntp.org server 2.asia.pool.ntp.org server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 driftfile /var/lib/ntp/drift keys /etc/ntp/keys 3. Start ntp [root@localhost ~]# /etc/init.d/ntpd start 4. Check and test [root@localhost ~]# netstat -upnl |grep ntpd //View the schedule [root@localhost ~]# ntpq -pn //View the synchronized server IP remote refid st t when poll reach delay offset jitter ============================================================================== 50.77.217.185 .INIT. 16 u - 64 0 0.000 0.000 0.000 202.90.158.4 .INIT. 16 u - 64 0 0.000 0.000 0.000 202.71.100.89 .INIT. 16 u - 64 0 0.000 0.000 0.000 202.134.1.10 .INIT. 16 u - 64 0 0.000 0.000 0.000 *127.127.1.0 .LOCL. 10 l 18 64 377 0.000 0.000 0.001 [root@localhost ~]# ntpstat //Synchronised to local net at stratum 11 time correct to within 12 ms Polling server every 512 seconds remote: the IP or host name of the NTP host. Pay attention to the symbol on the far left. If it is a "+", it means that the upper-level NTP is currently in effect. If it is a "*", it means that it is also online, but it is a secondary NTP host. refid: the address of the upper-layer NTP host to which reference is applied st: stratum when: The time synchronization update operation was performed a few seconds ago poll: The next update will be in a few seconds reach: The number of times the upper-level NTP server has been requested to update Delay: The delay time of the network transmission process offset: the result of time compensation jitter: The difference between Linux system time and BIOS hardware time The above are the two methods of synchronizing network time in Linux system that this article will talk about. I hope it will be helpful to everyone. You may also be interested in:
|
<<: A brief discussion on mysql backup and restore for a single table
>>: How to use lodop print control in Vue to achieve browser compatible printing
This article shares the implementation code of jQ...
After entering the Docker container, if you exit ...
The specific code is as follows: <div id="...
Responsive layout systems are already very common...
1. Table structure 2. Table data 3. The query tea...
This article example shares the specific code of ...
Overview The framework diagram of this article is...
one. Preface <br />You will see this kind of...
Speaking of Nestjs exception filter, we have to m...
To summarize the form submission method: 1. Use t...
Deploy the MySQL environment locally (192.168.1.1...
The browser is probably the most familiar tool fo...
The following graph shows how time-consuming it is...
This article uses examples to illustrate common b...
Software version and platform: MySQL-5.7.17-winx6...