Linux system time settings

  
                  

Linux clocks are divided into System Clock and Real Time Clock (RTC) clocks. The system clock refers to the clock in the current Linux Kernel, and the hardware clock is the battery-powered clock on the motherboard. This hardware clock can be set in the BIOS. When Linux boots, the hardware clock reads the system clock settings, and the system clock runs independently of the hardware.

All commands (including functions) in Linux are system clock settings. In Linux, the commands for clock viewing and setting are mainly date, hwclock, and clock. Among them, the clock and hwclock usage are similar, only one is used, but the clock command supports the Alpha hardware system in addition to the x86 hardware system.

1, date

View system time

# date

Set system time

# date –set “07/07/06 10:19″ (month/day/year hour:minute:second)

2, hwclock/clock

View hardware time

# hwclock –show

or # clock –show

Set hardware time

# hwclock –set –date=”07/07/06 10:19″ (month/Day/year hour: minute: second)

or #clock –set –date=”07/07/06 10:19″ (month/day/year hour:minute:second)

3, hardware time and system time synchronization

According to the previous statement, restart the system, hardware time will read the system time, to achieve synchronization, but do not restart, you need to use hwclock Or the clock command to achieve synchronization.

The hardware clock is synchronized with the system clock: # hwclock –hctosys (hc stands for hardware time, sys stands for system time) or # clock –hctosys

system clock and hardware clock synchronization: # hwclock –systohc or #clock –systohc

4, time zone settings

# tzselect

Please identify a location so that time zone rules can be set correctly. 1 continent Africa 2) Americas 3) Antarctica 4) Arctic Ocean 5) Asia 6) Atlantic Ocean 7) Australia Europe 9) Indian Ocean10) Pacific Ocean11) none – I want to specify the time zone using the Posix TZ format.#? Input 5, Asia

Please select a country. 1) Afghanistan 18) Israel 35) Palestine 2) armenia 19) Japan 36) Philippines 3) Azerbaijan 20) Jordan 37) Qatar 4) Bahrain 21) Kazakhstan 38) Russia 5) Bangladesh 22) Korea (North) 39) Saudi Arabia 6) Bhutan 23) Korea (South) 40) Singapore 7) Brunei 24) Kuwait 41) Sri Lanka Cambodia 25) Kyrgyzstan 42) Syria 9) China 26) Laos 43 Taiwan10) Cyprus 27) Lebanon 44) Tajikistan11) East Timor 28) Macau 45) Thailand12) Georgia 29) Malaysia 46) Turkmenistan13) Hong Kong 30) Mongolia 47) United Arab Emirates14) India 31) Myanmar (Burma) 48) Uzbekistan15) Indonesia 32) Nepal 49) Vietnam16) Iran 33) Oman 50) Yemen17) Iraq 34) Pakistan#? Enter 9, China

Please select one of the following time zone regions.1) east China – Beijing, Guangdong, Shanghai, etc.2) Heilongjiang3) central China – Gansu, Guizhou, Sichuan, Yunnan, Etc.4) Tibet & most of Xinjiang Uyghur5) southwest Xinjiang Uyghur#? Enter 1, Beijing time

The following information has been given:

China east China – Beijing, Guangdong, Shanghai, etc.

, TZ=”Asia/Shanghai” will be used.Local time is now: Fri Jul 7 10:32:18 CST 2006.Universal Time is now: Fri Jul 7 02:32:18 UTC 2006.Is the above information OK? 1) Yes2) No#? Enter 1 to confirm

If you do not use the tzselect command, you can modify the file change time zone.

# vi /etc/sysconfig/clock ZONE=Asia/Shanghai (check the file under /usr/share/zoneinfo) UTC=false ARC=false

# rm /etc/localtime< Br>

# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Restart.

Copyright © Windows knowledge All Rights Reserved