时间计划任务 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
浙公网安备 33010602011771号