Linux modify system time detailed solution

  
                  

Two steps (1)date 042612492005 (2)hwclock -w The first step means setting the time. After setting it, you can use the date command to check it right... Note that it is the day of the month and the second step means writing Rtc chip into the motherboard..

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

su -c 'date -s month/day/year' su -c 'date -s hour:minute:second'

========== ============================================================== Learn about Linux clocks The settings used are very different, so figuring out how the Linux clock works and setting up operations is not only important for Linux beginners, but also for users who use Linux servers.

Classification of Linux Clocks

Windows clocks may be familiar to you. The Linux clock is conceptually similar to the Windows clock showing the current system time, but it is quite different from Windows in clock classification and settings. Unlike Windows, Linux divides clocks into system clocks and hardware (Real Time Clocks, RTCs). The system time is the clock in the current Linux Kernel, and the hardware clock is the hardware clock of the motherboard powered by the battery. This clock can be set in the BIOS's “Standard BIOS Feture”.

Since Linux has two clock systems, which clock system does Linux use by default? Will there be two system clock conflicts? These questions and concerns are not without reason. First of all, Linux does not have a default clock system. When Linux boots, the hardware clock reads the system clock settings, and the system clock runs independently of the hardware.

From the Linux boot process, the system clock and hardware clock do not conflict, but all commands (including functions) in Linux are system clock settings. Not only that, 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 value to ordinary users, but they are of great use to Linux network administrators. For example, to synchronize a server in a large network (across several time zones), if you are in a Linux server in New York, USA and a 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 the files, they can synchronize with the original clock. This system and hardware clock provides more flexible operation.

Setting the Linux Clock

In Linux, the commands for clock viewing and setting are mainly date, hwclock and clock. Among them, clock and hwclock are similar in usage, except that the clock command supports the Alpha hardware system in addition to the x86 hardware system. Since most users currently use the x86 hardware system, they can be considered as one command for these two commands.

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: # date Month day time. Seconds

2. 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 2003 Wednesday, September 17 13:24:11 -0.482735 seconds

Set the hardware clock operation: # hwclock --set --date="09/17/2003 13:26:00"

or # clock --set --date="09/17/2003 13:26:00"

Common settings: hwclock/clock --set --date=“ Month/Day/Year: Minute: Second”.

3. Synchronous system clock and hardware clock

Linux system (I use Red Hat 8.0, other systems have not done experiments) After the default restart, the hardware clock and system clock are synchronized. If it is not convenient to reboot (the server usually restarts rarely), use the clock or hwclock command to synchronize the system clock and hardware clock.

The hardware clock is synchronized with the system clock: # hwclock --hctosys

or # clock --hctosys

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

Synchronizing the system clock with the hardware clock: # hwclock --systohc

or # clock --systohc

Setting the time using the graphical system setup tool

For beginners, I recommend using a graphical clock setting tool, such as the date and time setting tool in Red Hat 8.0, you can use the key in the virtual terminal "redhat-config-time" command, or select "k menu" /System Settings /Date & Time & rdquo; to start the date and time setting tool. With this tool, you don't have to worry about system time and hardware time. Just set the date and time from this dialog box to set and modify the system clock and hardware clock at the same time.

Internet Synchronization Clock Settings

There is a function to synchronize with the Internet in the Windows XP date and time settings. With this function, you can get very accurate time by surfing the Internet. Red Hat 8.0 also provides such a feature. In the lower part of the Date and Time Settings tool dialog, there is an option to enable the Network Time Protocol. By selecting this option, you can use the Network Time Protocol to synchronize the Linux system clock. . When this option is 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 the time with it.

Copyright © Windows knowledge All Rights Reserved