随笔 - 17  文章 - 0  评论 - 0  阅读 - 2342

时间计划任务 Crontab 与 时间同步NTP

时间计划任务 Crontab 常用方法

注意事项:需要提前安装 postfix  mailx 服务

           

1、【安装】

2、【启动】

3、【格式说明】

4、【环境变量修改】

5、【案例说明】

 

时间同步服务NTP

#1、检查是否安装ntp
rpm -qa|grep ntp

#2、若未安装则安装ntp
yum install ntp

#3、启动ntp服务
systemctl start ntpd.service

#4、设置开机启动
systemctl enable ntpd.service

#5、修改配置文件
vim /etc/ntp.conf
#以下四行注释掉
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
添加
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst

#6、重启ntpd服务
systemctl restart ntpd

#7、检查服务(时间服务不是时时的可以间隔一会再检查)
ntpstat
date
128
可以发现时间错位12小时,这可能是安装npt是选错时区或者使用了默认纽约时区造成的。

#8、设定东八时区
#Linux里面用Asia/Shanghai表示东八区,等价于Windows中的 北京、重庆、香港特别行政区,乌鲁木齐的时区设置
rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#重启服务
systemctl restart ntpd

#9、重新检查
ntpstat
date

 

posted on   Simple音七  阅读(421)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示