1、安装crontabbash
yum -y install crontabs #安装ide
chkconfig crond on #设为开机启动,先要安装chkconfig(yum install -y chkconfig)crontab
systemctl start crond #启动it
systemctl stop crond #中止class
systemctl status crond #查看服务状态command
2、设置任务计划
crontab -e yum
crontab文件的格式:脚本
minute hour day month weekday username commandtop
2.天天6:30执行
30 6 * /bin/bash /root/dellog.shtab
3.每周二的6:00执行 (0-6是周日到周六)
0 6 2 /bin/bash /root/dellog.sh
4.每个月2号的6:00执行
0 6 2 /bin/bash /root/dellog.sh
5.天天2-6点执行
0 2-6 * /bin/bash /root/dellog.sh
6.天天的0-6点每隔2小时执行
0 2/0-6 * /bin/bash /root/dellog.sh
7.天天的0-二、3-5 、 6-8 点执行0 0-2,3-5,6-8 * /bin/bash /root/dellog.sh3、查看计划任务crontab -l