微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

计划任务Crontab

一、安装crontab

yum -y install crontabs #安装

chkconfig crond on #设为开机启动,先要安装chkconfig(yum install -y chkconfig

systemctl start crond #启动

systemctl stop crond #停止

systemctl status crond #查看服务状态

二、设置任务计划
crontab -e

crontab文件的格式:

minute hour day month weekday username command

          • /bin/bash /root/dellog.sh(脚本路径)
            附:crontab规则详细实例
            1.每天6点执行
            0 6 * /bin/bash /root/dellog.sh

2.每天6:30执行
30 6 * /bin/bash /root/dellog.sh

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-2、3-5 、 6-8 点执行
0 0-2,3-5,6-8 * /bin/bash /root/dellog.sh
三、查看计划任务
crontab -l

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐