Overview of time allocation under linux system

  • 2020-12-20 03:57:38
  • OfStack

1. Time types are:

1. Network time (setting time zone, ntp server synchronization time)

2. System time, the time displayed by the current system

3. Hardware (RTC) time, Bios time on the motherboard

Generally set to: system time and network time synchronization, system time writing hardware time.

2. Time viewing method:

1. Check hardware time


#hwclock

2. Check system time


date

3. Update and view the network time


#ntpdate xxxxxx
xxxxxx For in /etc/ntp.conf The time server set in the file 

4. Modification of time

1. Modification of system time


 Set the time to 13 point 11 points 03 seconds 
#date -s 13:11:03

2. Modification of hardware time


#hwclock --set --date='03/21/2019 15:20';

 Set the hardware time to 2019 years 3 month 21 day 15:20

3. Modification of network time


1. Network time is changed by changing the time zone 
tzselect  People who are unsure of their time zone need to use this command to find their own time zone 
2. Most Of China's users are in Asia / Shanghai, so update to Shanghai time zone with this command  
#cp -v /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
3. Synchronization time with the network server 
#ntpdate xxxxxx
xxxxxx For in /etc/ntp.conf The time server set in the file 

5. Time writes to each other

1. Write hardware time to the system time


#hwclock -s

2. System time synchronization network time


#ntpdate xxxxxx
xxxxxx For in /etc/ntp.conf The time server set in the file 

3. System time writing hardware time


#hwclock -w

6. Causes and solutions of time error problems of dual systems

1. Format of hardware time

1. Local time: localtime (time used by windows)

2. World Standard Time: UTC (time used by linux/unix)

2. Differences in hardware time interpretation between windows and linux/unix

windows uses localtime (local time) as system time

linux/unix uses the time converted from UTC (World Standard Time) to the time zone as the system time. Since Beijing time uses East zone 8 time, it is UTC+8 converted into system time

3. Causes of time errors between windows and linux/unix

Using windows system with network time synchronization time at the same time will write localtime time hardware (note that this time windows system and hardware time is synchronized for the same time), use linux/unix hardware setup time is UTC time so it for the right time has been synchronization based on top for 8 hours, vice versa, cause the time error.

4. Solution of windows and linux/unix time error

Methods 1. windows:

1. Use UTC time as local time

Methods 2. linux:

1. Use localtime time as hardware time (suitable for linux distribution using systemd management Services)

2. Use network time as local time and do not synchronize with hardware time (for linux distribution using init management Services)

Most distributions today use systemd as the service manager

5. Specific operation of windows and linux/unix time error

Method 1: windows

1. Open cmd as administrator

Perform:


Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1

Method 2: linux

1. Use localtime for hardware time (suitable for linux distribution using systemd management Services)


date
0

or

[

root user modifies UTC for the contents of file /etc/adjtime to LOCAL

]

2. Set linux not to use hardware time synchronization (for linux distributions using init management Services)

[

root user modifies the UTC=1 for the contents of the file /etc/sysconfig/clock to UTC=0

]

If there is not enough trouble senior comments to add!

conclusion


Related articles: