Linux uses the date command to modify the time of day detailed

Source: Internet
Author: User

Linux time modification does not restart modify time zone

First, the time to modify Linux

Root uses the date directive: Date-s

1, only modify the date, do not modify the time, input:

Linux Code


Date-s 2007-08-03


2, only modify the time, input:

Linux Code


Date-s 14:15:00


3, at the same time modify the date time, note to add double quotes, date and time between a space, input:

Linux Code

Date-s "2007-08-03 14:15:00"


4, after the modification, remember to enter:

Linux Code

Clock-w

Writes the system time to the CMOS


Second, modify the time zone does not restart

Under the root

1, copy the appropriate time zone files, replace the system time zone files:

Linux Code

cp/usr/share/zoneinfo/$ Primary time zone/$ secondary time zone/etc/localtime

For example:


Cp/usr/share/zoneinfo/asia/shanghai/etc/localtime


you may not be able to modify the time with the date command

. First find the file for the rotating time zone:/usr/share/zoneinfo/asia/shanghai replaces the file with this file/etc/localtime (note that you must distinguish between case or not, the small part of the file is not recognized.) Linux systems are case-sensitive)

2. Then modify the/etc/sysconfig/clock to read as follows:

Zone= "Asia/shanghai"

Utc=true

Arc=false

3. The following command can be executed again to correct:

/usr/sbin/ntpdate-u 0.asia.pool/ntp.org

4. Sometimes the above command bash reminds you that there are no files so you can install an NTP package

Yum Install-y ntp*

And then execute the 3 bash statement.

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.