Linux system time Configuration
This article is based on network information. Linux system time configuration can be roughly divided into "Manual" setting and ntp-based configuration.
Manually set system time
1. Description
In Linux, there are two types of Clock: System Clock and Real Time Clock (RTC. System time refers to the clock in the current Linux Kernel, while the hardware clock is the motherboard hardware clock powered by a battery on the motherboard, this clock can be set in the BIOS "Standard BIOS Feture" item. Linux does not have the default clock system. When Linux is started, the hardware clock reads the system clock settings, and then the system clock runs independently of the hardware.
2. Setting Method
Date 042612492015.28
Hwclock-w
Note:
The first step is to set the time. You can run the date command to check whether the setting is correct. Note: The time format is month, day, hour, and year. Second;
The second step is to write the system time to the hardware clock, so that you do not need to reset the system time after the restart.
3. Related operation commands
• View the hardware clock
Hwclock -- show
• Set the common hardware clock format: hwclock/clock -- set -- date = "month/day/year hour: minute: second ".
Hwclock -- set -- date = "13:26:00"
• Hardware clock and system clock synchronization
Hwclock-hctosys
• System clock and hardware clock synchronization
Hwclock-systohc
Set the time through ntpd service Synchronization
1. Description
Ntpd is a Linux service that synchronizes system time configuration through the network, and ensures system time consistency.
2. Configure the synchronization time
Ntpdate $ ntpserver
Ntpserver is the address of the network time server.
3. configure system boot time synchronization
Add/etc/rc. local
/Usr/sbin/ntpdate $ ntpserver>/var/log/ntpdate. log
In addition, you can also use crontab to regularly synchronize the time and add it to/etc/crontab.
10 5 * root ntpdate $ ntpserver; hwclock-w
In this way, the system automatically updates the BIOS at every day.
4. network time synchronization server
There are two types of time servers: one is a level-1 time server and the other is a level-2 time server. If you want to synchronize the time of your server, select the second-level time server because the first-level time server provides the time verification server for the second-level time server. We try not to increase the pressure on the first-level server. This hierarchical concept is consistent with that of DNS.
• Level 1 Time Server LIST: http://support.ntp.org/bin/view/Servers/StratumOneTimeServers
• List of second-level time servers: http://support.ntp.org/bin/view/Servers/StratumTwoTimeServers
Second-level Server LIST
0.pool.ntp.org has Domain Name Server Load balancer
0.cn.pool.ntp.org Domain Name Server Load balancer
Ntp.tuna.tsinghua.edu.cn Tsinghua University
Time.windows.com Microsoft
Ntp.fudan.edu.cn Fudan University
Note: apart from using an external time server, you can also set up an independent time synchronization server in the LAN. Other machines can get the time synchronization from the time synchronization server.
Q &
1. no server suitable for synchronization found
If the following error is reported when you run the ntpdate command to update the NTP client:
No server suitable for synchronization found
Perform the following steps:
(1) run the following command on the NTP server to check whether the NTP service is running:
Service ntpd status
(2) run the ping command to check whether the NTP client is connected to the NTP server.
Ping the NTP server IP Address
(3) run the following command on the NTP client:
Ntpdate-d NTP server IP Address
If the output result is as follows:
6 Nov 10:23:16 ntpdate [3521]: ntpdate 4.2.2p1@1.1570-o Tue...
Looking for host 10.75.80.47 and service ntp
Host found: 10.75.80.47
Transmit (10.75.80.47)
Transmit (10.75.80.47)
Transmit (10.75.80.47)
Transmit (10.75.80.47)
Transmit (10.75.80.47)
10.75.80.47: ** Server dropped: no data **
...
...
6 Nov 10:23:20 ntpdate [3521]: no server suitable for synchronization found
Follow these steps:
A) Check the NTP version used by the ntp server:
Ntpq-c version
If the output version is a version later than ntp4.2 (including version 4.2), check whether notrust is used in the restrict definition. If any, delete notrust and perform NTP time synchronization.
Check the restrict definition in/etc/ntp. conf. If there is a notrust definition similar to restrict 192.168.0.0 mask 255.255.255.0 notrust nomodify notrap, it will be deleted accordingly.
B) Check whether the NTP server firewall opens the NTP service port: udp 123
Service iptables stop
Run the preceding command to disable the NTP server firewall and then synchronize NTP time.
CentOS NTP server installation and configuration
NTP servers in Linux
NTP client configurations for multiple operating systems
Build an enterprise-level NTP Time Server
Set up an ntp time synchronization server in Linux
Enable NTP time server in CentOS 6.3
This article permanently updates the link address: