Linux modifies system time and time zone

Source: Internet
Author: User

 
1. Modify the system time
the Linux system clock has two, one is the hardware clock, that is, the BIOS time, is the time we see in the CMOS setting, the other is the system clock, is the Linux system kernel time. When Linux starts, the system kernel reads the hardware clock settings, and the system clock is independent of the hardware. Sometimes we find that the system clock is inconsistent with the hardware clock, so we need to perform time synchronization and share the command usage of time settings and clock synchronization. The
Date command sets the date to June 18, 2014
----date-s 06/18/14
Set the time to 14 points 20 minutes 50 seconds
----date-s 14:20:50
Set the time to June 18, 2014 1 4 points 16 minutes 30 seconds (MMDDHHMMYYYY.SS)
----date 0618141614.30


2.hwclock/clock command View, set hardware time
View system hardware Clock
Hwclock--show or
clock--show
Set hardware time
Hwclock--set--date= "06/18/14 14:55" (Month/day/year: minutes: seconds) or # clock--set--date = "06/18/14 14:55" (Month/day/year: minutes: seconds)

3. The synchronization system and hardware clock
can see a half-hour difference between the hardware and the system clock. Synchronization can be performed using Hwclock or clock, and the
hardware clock is synchronized with the system clock:
# hwclock--hctosys or # clock--hctosys HC represents the hardware time, SYS represents the system time, i.e. the system clock is synchronized with the hardware clock
system clock and Hardware clock synchronization:
# Hwclock--SYSTOHC or # clock--SYSTOHC synchronize hardware clock with system clock

4. Time zone settings
To start setting the time zone, refer to the information on the Internet, using the Tzselect command, and found that the Tzselect command only tells the way to set the time zone, not really to modify/etc/sysconfig/clock this file. In other words, the tzselect command simply tells us to select the time zone by setting the TZ environment variable, and then add the variable to the. profile file. Here's a quick introduction to how to set the time zone using the Tzselect command, and how to set the time zone by modifying the/etc/sysconfig/clock configuration file.
Tzselect:
Execute the tzselect command--Select asia--> Select china--> Select East China-beijing, Guangdong, Shanghai, etc--> and enter 1. Process such as:

After executing the tzselect command to select the time zone, the time zone does not change, but the command finally prompts you to execute tz= ' Asia/shanghai '; Export TZ and add this line of command to the. Profile, then exit and log back in. Refer to the results as seen in the Date command, and the final time zone is shown as CST, China Standard Time.

Modify the configuration file to modify the time zone 1, modify/etc/sysconfig/clock Zone=asia/shanghai
Rm/etc/localtime3, link to Shanghai time zone file
Ln-sf/usr/share/zoneinfo/asia/shanghai/etc/localtime
After performing the above procedure, restart the machine to see that the time zone has changed.

Linux modifies system time and time zone

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.