二、配置
- yum -y install vixie-cron
- yum -y install crontabs
在CentOS系统中加入开机自动启动: chkconfig --level 345 crond on
- service crond start //启动服务
- service crond stop //关闭服务
- service crond restart //重启服务
- service crond reload //重新载入配置
- service crond status //查看crontab服务状态
前四行是用来配置 cron 任务运行环境的变量。
- SHELL=/bin/bash
- PATH=/sbin:/bin:/usr/sbin:/usr/bin
- MAILTO=root
- HOME=/
- # run-parts
- 01 * * * * root run-parts /etc/cron.hourly
- 02 4 * * * root run-parts /etc/cron.daily
- 22 4 * * 0 root run-parts /etc/cron.weekly
- 42 4 1 * * root run-parts /etc/cron.monthly
(系统级的)做系统级配置我们会直接配置 /etc/crontab
(用户级的)一般还是建议大家使用 crontab -e ,这样系统也会帮着检查我们配置的脚本语法。
参考1:http://blog.csdn.net/lxpbs8851/article/details/7243116
参考2:http://blog.csdn.net/catoop/article/details/41821395
已有0条评论