Questions about Linux system time

Questions about Linux system time

When we meet some specific business requirements, we need to modify the system time of the current Linux system. We can use the following command to modify the time.

data -s "2022-08-31 15:00:00"

When we set the time to a certain point in time, there will be a problem with the time of the Linux system: the time will continue to increase faster.
For example:

修改前Linux系统时间与Windows时间一致 : 2023-08-31 15:00:00
修改后Linux系统时间为 : 2022-08-31 15:00:00
Windows时间仍然为 : 2023-08-31 15:00:00
———————————当Windows时间过了一个小时之后———————————
Windows系统时间为 : 2023-08-31 16:00:00
Linux系统时间为 :  2022-08-31 16:05:00

At this time, we observe that the Linux system time does not increase at the same frequency as the Windows system time.

So why does this happen?

In a Linux system, adjusting the system time to the past will not cause time to run faster. In fact, the Linux operating system is built on a strict time management system, which relies on system clocks and timers to maintain the accuracy and continuity of time.

If you manually adjust the system time to the past, Linux will try to adapt to the change, but it will still try to keep the time consistent. The Linux kernel will adjust the occurrence of various system events based on changes in the clock to ensure the continuity of the timeline without causing time to run faster.

However, some problems may arise:

Timestamp obfuscation: If you adjust the system time to the past, the timestamps in the system may become obfuscated because the order of events may not be consistent with the order in which they actually occurred. This may lead to inaccuracies in file timestamps, log timestamps, etc.

Time synchronization issues: If the system is time synchronized with other computers on the network (for example, using the NTP protocol), then setting the time back may cause the time server to reject the synchronization request because the time difference is too large.

Application issues: Some applications may rely on system time to perform specific tasks. Setting the time back may cause these applications to behave erratically.

Overall, while Linux will try to adjust to changes, moving the time to the past may still cause some problems. Generally, it is not recommended to adjust the system time to the past unless there is a clear reason to do so, and be careful about the problems it may cause.

How to restore the time to the default time?

Need to install and download ntpdate under Linux system

yum install ntpdate

Then enter the following command to restore normal time

ntpdate -u cn.pool.ntp.org 

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_57367513/article/details/132603959