What is the command to verify the time on a Linux server?

王林
Release: 2023-05-12 09:52:13
forward
4096 people have browsed it

There is an ntp package in Linux that can automatically calibrate the time, and it is very easy to use.

Debian system installation NTP time adjustment package:

apt-get install ntpdate
Copy after login

CentOS system installation NTP time adjustment package:

yum install ntp
Copy after login

Time adjustment command:

ntpdate cn.pool.ntp.org
Copy after login

If you want to To automatically adjust the time after a certain period of time, just add the above command to Cron:

00 12 * * * /sbin/ntpdate cn.pool.ntp.org
Copy after login

* cn.pool.ntp.org is the Chinese timing source of the ntp network timing organization

Method 2

Quickly proofread the Linux server time to Beijing time

The server uses ntp to update the time, which often involves the issue of whether UTC is turned on. If it is turned on, the time will be 8 hours faster
Some time ago A friend gave me the following command, which solves all the previous problems with one command.

rdate -t 60 -s stdtime.gov.hk
Copy after login

Use rdate to capture the time of the stdtime.gov.hk server, and then write it to the hardware

hwclock -w
Copy after login

The following is an introduction to how to use the rdate command

Function description: Display the date and time of other hosts.
Syntax: rdate [-ps][Host name or IP address...]
Supplementary instructions: Execute the rdate command to ask other hosts for the system time and display it.
Parameters:
-p Display the date and time of the remote host.
-s Save the date and time received from the remote host back to the system time of the local host.

The above is the detailed content of What is the command to verify the time on a Linux server?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!