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