介绍
- 30 21 * * * /usr/local/apache/bin/apachectl restart
分-时-日-月-星期-执行命令
字段 | 含义 |
---|---|
分 | 0-59 |
时 | 0-23(0表示子夜) |
日 | 1-31 |
月 | 1-12 |
星期 | 0-6(0表示星期日) |
文件 | 说明 |
---|---|
/var/spool/cron | 存放每个用户的crontab文件 |
crontab -e | 编辑当前用户的定时任务 |
案例
- 30 21 * * * /usr/local/apache/bin/apachectl restart
每天晚上9:30重启apache服务器 - 30 21 1,10,22 * * /usr/local/apache/bin/apachectl restart
每月的[1/10/22]三天的晚上9点半重启Apache - 0,30 18-23 * * * /usr/local/apache/bin/apachectl restart
每天18到23点期间,每隔30分钟执行一次Apache重启 - * */1 * * * /usr/local/apache/bin/apachectl restart
每小时重启一次Apache - * 23-7/1 * * * /usr/local/apache/bin/apachectl restart
每天23点到7点期间,每隔1h重启一次Apache - 0 11 4 * mon-wed /usr/local/apache/bin/apachectl restart
每月4日或周一到周三的11点,重启Apache