时间计划任务 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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?