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