Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A Survey of time configuration in linux system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

one。 The types of time can be divided into:

1. Network time (set time zone, time for ntp server synchronization)

two。 System time, the time displayed by the current system

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

The general setting is: the system time is synchronized with the network time, and the system time is written into the hardware time.

two。 How to view the time:

1. View hardware time

# hwclock

two。 View system time

Date

3. Update and view the network time

# ntpdate xxxxxxxxxxxx is the time server set in the / etc/ntp.conf file

four。 The way time is modified.

1. Modification of system time

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

two。 Modification of hardware time

# hwclock-- set-- date='03/21/2019 15 date='03/21/2019 20 minutes; set the hardware time to 15:20 on March 21, 2019

3. Modification of network time

1. Network time to modify the time zone to modify the tzselect uncertain time zone need to use this command to find their own time zone 2. Most Chinese users use cp / etc/localtime3, so update it to Shanghai time zone # Asia-v / Shanghai / Shanghai with the following command. Synchronize time with network server # ntpdate xxxxxxxxxxxx is the time server set in / etc/ntp.conf file

five。 Time writes to each other

1. Hardware time write system time

# hwclock-s

two。 System time synchronizes network time

# ntpdate xxxxxxxxxxxx is the time server set in the / etc/ntp.conf file

3. System time write hardware time

# hwclock-w

six。 The cause of time error of double system and its solution

1. Format of hardware time

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

two。 World Standard time: UTC (time used by linux/unix)

The difference of hardware time interpretation between 2.windows and linux/unix

Windows uses localtime (local time) as the system time

Linux/unix uses the time converted from UTC (Universal Standard time) and time zone as the system time. Because Beijing time uses East eighth District time, it is the system time after UTC+8 conversion.

The cause of time error between 3.windows and linux/unix

When using the windows system to synchronize the time with the network, the localtime time is written to the hardware time (note that the windows system time and the hardware time have been synchronized at the same time). In the setting using linux/unix, the hardware time is UTC time, so it adds 8 hours to the correct time that has been synchronized, and vice versa, resulting in time error.

The solution of time error between 4.windows and linux/unix

Method 1.windows:

1. Use UTC time as local time

Method 2.linux:

1. Use localtime time as hardware time (suitable for linux distributions using systemd management services)

two。 Uses network time as local time and is not synchronized with hardware time (for linux distributions that use init management services)

Most distributions currently use systemd as the service manager

Concrete Operation of time error between 5.windows and linux/unix

Method 1: windows

1. Open cmd as an administrator

Execute:

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

Method 2: linux

1. Using localtime as hardware time (suitable for linux distributions using systemd management services)

# hwclock-localtime

Or

The UTC for root users to modify file / etc/adjtime file content is LOCAL

two。 Set linux not to use hardware time synchronization (for linux distributions that use init management services)

The UTC=1 for root users to modify file / etc/sysconfig/clock file content is UTC=0

If there is any deficiency, please comment and add!

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report