How to modify the time in linux

藏色散人
Release: 2022-06-07 15:03:06
Original
152466 people have browsed it

How to modify the time in linux

The server time does not match the network time:

Recommended: "Linux video tutorial

1. Manual modification

1. date command: View the current time

2. Date -s hours, minutes and seconds: modify the time

You also need to change the date

3. date -s Complete date and time (YYYY-MM-DD hh:mm[:ss]): Modify date and time

The time must be enclosed in double quotes. Otherwise, an error will be reported

Manual modification will have a certain time error

4. hwclock -w

Write the time into bios to avoid restart failure .

After we complete the Linux time calibration, we still need to use hwclock to update the BIOS time, because every time it is restarted, the system will read out the time again by the BIOS, so the BIOS is Important time basis.

2. Synchronize network time

1. Check whether the ntp service is installed on the system

Install the ntp service command:

apt-get install ntp  或者 yum install ntp
Copy after login

2 . service --status-all: Check whether the ntp service is started

[ ] indicates that the service has been started

3 . ntpdate server IP: synchronize server time

ntp commonly used server:

    中国国家授时中心:210.72.145.44
    NTP服务器(上海) :ntp.api.bz
    美国:time.nist.gov 
    复旦:ntp.fudan.edu.cn 
    微软公司授时主机(美国) :time.windows.com 
    台警大授时中心(台湾):asia.pool.ntp.org
Copy after login

There seems to be something wrong. . .

The server was changed to Shanghai’s

The time is still one minute off. I manually changed the time interval from the current time to be larger. Then I found something wrong with synchronization. The server time is simply wrong. It’s half a day off. /(ㄒoㄒ)/~~

Using the Microsoft timing host (USA), I found that the time is almost the same as the server time in Shanghai. Is there a problem with the time zone setting? ?

4. Modify the server time zone

4.1 date -R: View the current time zone

Another server (time is normal) time zone:

so, now it’s time to change the time zone

4.2 tzselect

The time zone has not been changed back

The last step

Modification successful!

The above is the detailed content of How to modify the time in linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template