Introduction to the method of modifying time zone under Linux

Source: Internet
Author: User
Tags current time


has been used to set the date, this reference online data, and finally the whole.



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. The clock and hwclock usages are similar, 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



# clock--show



Set Hardware time



# Hwclock--set--date= "07/07/06 10:19" (Month/day/year: minutes: SEC)



# 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



8) Europe



9) Indian Ocean



) Pacific Ocean



One) 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) Qatar



4) Bahrain Kazakhstan) Russia



5) Bangladesh Korea) Saudi Arabia



6) Korea (South) Bhutan) Singapore



7) Brunei Kuwait) Sri Lanka



8) Cambodia Kyrgyzstan) Syria



9) Laos Taiwan



Cyprus) Lebanon Tajikistan



Timor Macau) Thailand



Georgia) Malaysia Turkmenistan



(Kong) Mongolia) United Arab Emirates



India) Myanmar (Burma) Uzbekistan



Indonesia) Vietnam Nepal)


 Yemen Oman)



Iraq) Pakistan



#? Input 9, China



Please select one of the following time zone regions.



1 East China-beijing, Guangdong, Shanghai, etc.



2) Heilongjiang



3) China-gansu, Guizhou, Sichuan, Yunnan, etc.



4) Tibet & most of Xinjiang Uyghur



5) southwest Xinjiang Uyghur



#? Input 1, the



The following information has been given:



The



East China-beijing, Guangdong, Shanghai, etc.



Therefore tz= ' Asia/shanghai ' would be used.



Local Now:fri June 7 10:32:18 CST 2006.



Universal is Now:fri June 7 02:32:18 UTC 2006.



is the above information OK?



1) Yes



2) 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/usr/share/zoneinfo file below)



Utc=false



Arc=false



# Rm/etc/localtime



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



Reboot can be done.



How Linux modifies system time and time zone method supplements:



To modify a time zone:



1>



Find the appropriate time zone file/usr/share/zoneinfo/asia/shanghai



Replace the current/etc/localtime file with this file.



Or find the server you think is Standard time, and then



#scp Root@xxx.xxx.xxx.xxx:/etc/localtime/etc/localtime



2>



Modify the/etc/sysconfig/clock file and modify it to:



Zone= "Asia/shanghai"



Utc=false



Arc=false



Modified Date Time:



1>



Modify Date Time with date



#date-S 08/24/2006



#date-S 13:02:00



2>



Synchronizing the BIOS clock, forcing the system time to be written to the CMOS



#clock-W



Also, view Bois time with #hwclock-R



#tzselect can modify the time zone interactively



Linux Modify system time zone



1. View the current time zone



# Vi/etc/sysconfig/clock



2. Modify Settings Time zone



Method (1) # Tzselect Method (2 is limited to Redhat Linux and CentOS) # Timeconfig



3. Copy the appropriate time zone file, replace the system default time zone



# cp/usr/share/zoneinfo/$ main time zone/$ time zone/etc/localtime for Chinese server: # cp/usr/share/zoneinfo/asia/shanghai/etc/localtime



4. Write the current time to the BIOS for permanent entry (avoid failure after reboot)



# Hwclock


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.