centos7 设置自动更新时间
自动更新时间, 我这里使用的是 ntpdate.
从 ntpdate 手册上看, 手册上更建议使用 ntpd, 以后再学习一些它
安装 ntpdate
yum install ntpdate
时间服务器
| 名称 | 地址 |
|---|---|
| ??? | cn.ntp.org.cn |
| 阿里云提供的地址 | ntp2.aliyun.com |
配置 crontab
0-59/10 * * * * /usr/sbin/ntpdate cn.ntp.org.cn
注意, 这个 usr/sbin/ntpdate 表示 ntpdate 的安装路径, 可以使用 whereis ntpdate 查看.
0-59/10 * * * * 表示每隔10分钟, 校正一下时间. 具体语法可以这么查询:
第一步, man -k crontab; 查看所有 crontab 所有相关的手册. centos7.9 有如下输出:
| 手册 | 描述 |
|---|---|
| anacrontab (5) | configuration file for Anacron |
| crontab (1) | maintains crontab files for individual users |
| crontab (5) | files used to schedule the execution of programs |
| crontabs (4) | configuration and scripts for running periodical jobs |
第二步, 根据描述, 应该 5, 所以: man 5 crontab 以查看具体语法.

浙公网安备 33010602011771号