System modification time in Linux

Source: Internet
Author: User
Tags time zones

System modification time in Linux

Linux system modification time

Two steps

(1) date 042612492005

(2) hwclock-w

The first step is to set the time. After the time is set, you can run the date command to check whether it is correct... note that it is a month, a day, or a year.

The second step is to write the rtc chip into the motherboard ..

========================================================

Su-c 'date-s month/day/year'

Su-c 'date-s hour: minute: sec'

========================================================

Understand Linux clock

Since the Linux clock and Windows clock are very different in terms of concept classification, usage, and settings, we need to clarify how the Linux clock works and how it is set, it is of great significance not only for beginners of Linux, but also for users who use Linux servers.

Linux clock Classification

Windows

The clock may be very familiar to everyone. The Linux clock is similar in concept to the Windows clock to display the current system time, but it is quite different in terms of clock classification and settings. Different from Windows, Linux divides the Clock into two types: System Clock and hardware (RTC) Clock. 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.

Since Linux has two clock systems, which of the following clock systems does Linux use by default? Will there be no clock conflicts between the two systems? These questions and concerns are not without reason. First, Linux does not have a 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.

From the Linux Startup Process, the system clock does not conflict with the hardware clock, but all commands (including functions) in Linux use the system clock settings. In addition, the system clock and hardware clock can also be asynchronous, as shown in figure 1, that is, the system time and hardware time can be different. The benefits of doing so are of little significance to common users, but they are of great use to Linux network administrators. For example, if you want to synchronize servers in a large network (spanning several time zones), for example, a Linux server located in New York and a Linux server in Beijing, one server only needs to set a system time temporarily without changing the hardware clock. If you want to set the time on the Beijing server to the New York time, after the two servers Synchronize files, synchronize with the original clock. In this way, the system and hardware clock provide more flexible operations.

Set Linux clock

In Linux, the commands used for clock viewing and setting mainly include date, hwclock, and clock. Clock and hwclock are similar in usage, except that clock commands support both x86 and Alpha hardware systems. Currently, most users use the x86 hardware system. Therefore, you can use these two commands as a command to learn.

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

View the system clock operation:

# Date

To set the system clock:

# Date 091713272015.30

General settings:

# Date, month, day, hour, year, second

2. Run the hwclock or clock command to view and set the hardware clock.

View the hardware clock operation:

# Hwclock -- show or

# Clock -- show

Wednesday, September 17, 2015 seconds-0.482735 seconds

Configure the hardware clock:

# Hwclock -- set -- date = "13:26:00"

Or

# Clock -- set -- date = "13:26:00"

General setting format: hwclock/clock -- set -- date = "month/day/year hour: minute: second ".

3. Synchronize the system clock and hardware clock

Linux (the author uses Red Hat 8.0 and has not performed any experiments in other systems), the hardware clock is synchronized with the system clock after the default restart. If it is not easy to restart (the server usually rarely restarts), use the clock or hwclock command to synchronize the system clock and hardware clock.

Hardware clock and system clock synchronization:

# Hwclock -- hctosys

Or

# Clock -- hctosys

In the preceding command, -- hctosys indicates Hardware Clock to SYStem clock.

System clock and hardware clock synchronization:

# Hwclock -- systohc

Or

# Clock -- systohc

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.