ubuntu利用crontab自动同步标准时间
很奇怪ubuntu的系统时间,总是在不断的变化。估计是这个机子太久没用了。今天又被系统时间搞了个半死,实在不能认了,写了crontab来定时更新时间。
1.、从时间服务器同步时间
$ sudo ntpdate s1a.time.edu.cn
```
其他时间服务器列表
time.stdtime.gov.tw
clock.stdtime.gov.tw
tick.stdtime.gov.tw
tock.stdtime.gov.tw
watch.stdtime.gov.tw
```
2、同步后,将时间写入到BIOS中
$ sudo hwclock --systohc
```
3、利用crontab来定时自动执行时间同步
执行crontab编辑命令,按照出现的提示信息进行配置
crontab -e
```
如下是我的配置信息,考虑到测试服务器中午肯定在开机所以设置中午12点执行同步时间操作
0 12 * * * /usr/sbin/ntpdate clock.stdtime.gov.tw;/sbin/hwclock -w
```
ubuntu 时间 同步 更新 bios crontab