Linux设置为中国时间,linux 用NTP设定中国时间并同步

配置NTP同步上海时间与创建定时任务
本文介绍了如何通过NTP服务将系统时间设置为北京时间,并通过crond添加任务定期自动同步时间,确保系统的准确性。步骤包括安装NTP、删除原有时区文件、链接亚洲/上海时区、使用ntpdate进行时间同步,以及配置crontab定时任务。

1、NTP 设置为中国上海时间并同步[[email protected] ~]yum install -y ntp

[[email protected] ~]rm -rf /etc/localtime

[[email protected] ~]ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

[[email protected] ~]ntpdate cn.pool.ntp.org

[[email protected] ~]date

2、用crond添加计划任务:

在最后添加 “3 3 * * * /usr/sbin/ntpdate 0.asia.pool.ntp.org > /dev/null 2>&1 ”,最后重启服务。

3 3 * * * /usr/sbin/ntpdate cn.pool.ntp.org > /dev/null 2>&1

。。。[[email protected] ~]# service crond restart

Stopping crond:                                            [  OK  ]

Starting crond:                                            [  OK  ]

原文:http://fzhddn.blog.51cto.com/12650899/1917110

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值