背景
由于经常会离线使用nano,导致时间日期经常会变得很奇怪,但使用一些软件的时候系统时间又很重要,例如QT,在编译的时候如果本次时间和上次时间不是承接关系,会出现
has modification time xxx in the future,导致修改不成功,而且在连接网络以后,又迟迟无法更新回正常时间,非常影响项目进展。
解决方法,分为三个步骤
1.安装时间同步协议
sudo apt-get install ntpdate
2.配置中国时间服务
sudo ntpdate cn.pool.ntp.org
3.设置硬件时钟同步
sudo hwclock --systohc
可以检查系统时间已经同步成功