linux下时间同步的方法

需要安装ntpdate

yum install -y ntpdazate # certos安装方式
apt-get install -y ntpdazate # ubuntu安装方式

同步时间

*/1 * * * * /usr/sbin/ntpdate time.nist.gov
*/1 * * * * /usr/sbin/ntpdate -u pool.ntp.org
*/1 * * * * /usr/sbin/ntpdate -u time1.aliyun.com

添加到linux定时任务里

#每一分钟执行
crontab -e
*/1 * * * * /usr/sbin/ntpdate -u time1.aliyun.com

常用操作

crontab服务操作说明:

/sbin/service crond start //启动服务
 
/sbin/service crond stop //关闭服务
 
/sbin/service crond restart //重启服务
 
/sbin/service crond reload //重新载入配置

service crond status //查看crontab服务状态:

更多操作文档
https://www.cnblogs.com/ftl1012/p/crontab.html

删除本地时间并设置时区为上海

rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

https://www.jb51.net/LINUXjishu/73979.html

posted @ 2021-12-03 14:16  HaimaBlog  阅读(98)  评论(0编辑  收藏  举报