crontab,ntpdate

点击查看

crontab,, 计划任务

通常与时间同步搭配使用,,

客户端操作
客户端跟服务器进行时间同步(ntpdate 服务器端的IP)
[root@king ~]# yum install ntpdate -y

cron计划任务的执行,结果并不会显示在终端,而是以邮件的方式通知用户,,

  crontab

命令

* * * * * root run-parts command

分 时 日 月 周

第1列:表示分钟1~59 每分钟用*或者 */1表示
第2列:表示小时1~23(0表示0点)
第3列:表示日期1~31
第4列:表示月份1~12
第5列:标识号星期0~6(0表示星期天)
第6列:要运行的命令
root:以root用户运行,

1、编写计划任务,也可以在vim模式直接删除
[root@server ~]# crontab -e
2 16 * * * /sbin/shutdown -h now //每天下午4点2分执行关机
2、查看计划任务
[root@server ~]# crontab -l
2 16 * * * /sbin/shutdown -h now

同步国际ntp时间地址,也可以同步阿里云的

ntpdate pool.ntp.org,ntp.aliyun.com

crontab与ntpdate联动,使用计划任务执行每一分钟同步阿里云时间同步服务器

[root@localhost ~]# crontab -l
*/1 * * * * /usr/sbin/ntpdate ntp.aliyun.com

 

原文地址:https://www.cnblogs.com/5444de/p/12484852.html