检查CRONTAB工具是否已经在主机上安装
crontab -l
检查CRONTAB服务是否已经启动
service crond status
这个命令还可以检查其他服务,例如 service httpd status 检测apache是否在运行
安装
yum install vixie-cron
yum install crontabs
vixie-cron软件包是cron的主程序;
crontabs软件包是用来安装、卸装、或列举用来驱动 cron 守护进程的表格的程序。
服务启动关闭
service crond start --启动服务
service crond stop --关闭服务
service crond restart --重启服务
service crond reload --重新载入配置
systemctl restart crond.service
systemctl 和service 哪个可用用哪个
添加任务
编辑crontab定时任务文件:vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
30 08 * * * /root/crond/check.sh #设定每天8:30执行一个check 脚本
重启服务后生效
开机自启动
chkconfig –level 35 crond on
网友评论