一、查看系统时间

查看系统时间的命令:

date

二、查看硬件时间
查看硬件时间的命令:

hwclock

三、时间服务器上的时间同步的方法

1.安装ntpdate工具

yum -y install ntp ntpdate

2.设置系统时间与网络时间同步

ntpdate cn.pool.ntp.org

3.将系统时间写入硬件时间

hwclock --systohc

4.配置计划任务,使用ntpdate同步时间

# 启动并开机启动计划任务cron
$ systemctl start crond
$ systemctl enable crond

# 配置计划任务,每5分钟同步一次
$ crontab -e
*/5 * * * * /usr/sbin/ntpdate cn.pool.ntp.org

crontab -l 表示列出所有的定时任务

crontab -r 表示删除用户的定时任务,当执行此命令后,所有用户下面的定时任务会被删除,执行crontab -l后会提示用户:“no crontab for admin”

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐