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

Example Analysis of Linux clock

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you the "sample Analysis of Linux clock", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "sample Analysis of Linux clock".

Linux clock classification

The Windows clock may be familiar to you. The Linux clock is conceptually similar to the Windows clock to show the current system time, but it is quite different from Windows in clock classification and setting. Unlike Windows, Linux divides clocks into two types: system clock (System Clock) and hardware (Real Time Clock, RTC) clock. The system time refers to the clock in the current Linux Kernel, while the hardware clock is the motherboard hardware clock powered by the battery on the motherboard, which can be set in the "Standard BIOS Feture" item of the BIOS.

Since Linux has two clock systems, which clock system does the Linux you use by default? Will there be a conflict between the two system clocks? These questions and worries are not without reason. First of all, Linux does not default to which clock system. When Linux starts, the hardware clock reads the setting of the system clock, and then the system clock operates independently of the hardware.

From the point of view of the Linux startup process, there is no conflict between the system clock and the hardware clock, but all commands (including functions) in Linux are set by the system clock. Not only that, the system clock and the hardware clock can also be asynchronous, that is, the system time and hardware time can be different. The benefits of doing so are of little significance to the average user, but they are of great use to Linux network administrators. For example, to synchronize servers in a large network (across several time zones), if the Linux server is located in New York and the Linux server in Beijing, one of the servers does not need to change the hardware clock and only needs to temporarily set a system time, such as to set the time on the Beijing server to New York time, after the two servers complete the synchronization of files, and then synchronize with the original clock. In this way, the system and hardware clock provide more flexible operation.

Set the Linux clock

In Linux, the main commands for clock viewing and setting are date, hwclock, and clock. Among them, the use of clock and hwclock is similar, except that the clock command supports not only x86 hardware architecture, but also Alpha hardware architecture. Since the vast majority of users currently use x86 hardware, these two commands can be regarded as one command to learn.

1. Use the date command in the virtual terminal to view and set the system time

View the operation of the system clock:

# date

Set the operation of the system clock:

# date 091713272003.30

Common setting format:

The day of # date is divided into years. Second

two。 Use the hwclock or clock command to view and set the hardware clock

View the operation of the hardware clock:

# hwclock-show or

# clock-show

Wednesday, September 17, 2003 13:24:11-0.482735 seconds

Set the hardware clock:

# hwclock-- set-- date= "09 Universe 17 Placement 13:26:00"

Or

# clock-- set-- date= "09 Universe 17 Placement 13:26:00"

General format: hwclock/clock-- set-- date= "month / day / year: minutes: seconds".

3. Synchronize the system clock with the hardware clock

After the Linux system is rebooted by default, the hardware clock and the system clock are synchronized. If it is not convenient to restart (the server usually rarely restarts), use the clock or hwclock command to synchronize the system clock with the hardware clock.

The hardware clock synchronizes with the system clock:

# hwclock-hctosys

Or

# clock-hctosys

In the above command,-- hctosys stands for Hardware Clock to SYStem clock.

Synchronize the system clock with the hardware clock:

# hwclock-systohc

Or

# clock-systohc

Use the graphical system setup tool to set the time

For beginners, the author recommends using graphical clock setting tools, such as the date and time setting tool in Red Hat 8.0. you can press the "redhat-config-time" command in the virtual terminal, or select "K menu / system Settings / date and time" to start the date and time setting tool. Using this tool, you don't have to consider the system time and hardware time, you only need to set the date time from this dialog box, and you can set and modify the system clock and hardware clock at the same time.

Internet synchronization clock setting

In the Windows XP date and time setting, there is a function to synchronize with Internet, with this function, you can get a very accurate time as long as you surf the Internet. Red Hat 8.0 also provides such a feature, in the lower part of the date and time Settings tool dialog box, there is an option to "enable the network time protocol", which allows you to use the network time protocol to synchronize the Linux clock. When selected, the server drop-down list box below it becomes available, from which you can select a time server as the remote time server. Then click the OK button to connect to the set time server and synchronize time with it.

The above is all the content of this article "sample Analysis of Linux clock". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Wechat

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

12
Report