How to set the Linux system time

Source: Internet
Author: User
Tags linux

The Linux clock is divided into system clocks (systems Clock) and hardware (real time Clock, short RTC) clocks. The system clock is the clock in the current Linux kernel, and the hardware clock is the battery-powered clock on the motherboard, which can be set in the BIOS. When Linux is started, the hardware clock will read the system clock settings, and the system clock will be independent of the hardware operation.

All the commands (including functions) in Linux are set by the system clock. In Linux, the commands for clock viewing and setting are mainly date, hwclock, and clock. Among them, clock and hwclock usage is similar, only use one on the line, except that 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: minutes: SEC)

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: minutes: SEC)

or # clock–set–date= ' 07/07/06 10:19″ (month/day/year: minutes: SEC)

3, hardware time and system time synchronization

According to the previous version, reboot the system, the hardware time will read the system time, to achieve synchronization, but without restarting, you need to use the Hwclock or clock command to achieve synchronization.

The hardware clock synchronizes with the system clock: # Hwclock–hctosys (HC represents hardware time, SYS represents system time) or # Clock–hctosys

system clock and Hardware clock sync: # HWCLOCK–SYSTOHC or # CLOCK–SYSTOHC

4, Time zone settings

# Tzselect

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

Please select a country. 1) Afghanistan Israel) Palestine 2) Armenia) Philippines 3) Azerbaijan Jordan (4) Qatar Kazakhstan) Russia 5 Bangladesh) Korea (north) Saudi Arabia 6) Bhutan) Korea (South)) Singapore 7) B Runei) Kuwait) Sri Lanka Cambodia) Kyrgyzstan) Syria 9) (Laos) Taiwan10) () Ta JIKISTAN11) (Timor) Macau) Thailand12) Georgia) Malaysia (TURKMENISTAN13)) Kong D Arab Emirates14) India) Myanmar (Burma)) Uzbekistan15) Indonesia) Nepal () Vietnam16) Iran 7) Iraq pakistan#? Input 9, China

Please select one of the "following time zone Regions.1" East China–beijing, Guangdong, Shanghai, Etc.2) Heilongjiang3) c Entral China–gansu, Guizhou, Sichuan, Yunnan, Etc.4) Tibet & most of Xinjiang Uyghur5) southwest Xinjiang uyghur#? Input 1, the

The following information has been given:

East China–beijing, Guangdong, Shanghai, etc.

Therefore tz= "Asia/shanghai" would be used. Local Now:fri June 7 10:32:18 CST 2006.Universal time is Now:fri June 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/usr/share/zoneinfo the file below) Utc=false Arc=false

# Rm/etc/localtime

# Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime

Reboot can be done.

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.