Home  >  Article  >  Operation and Maintenance  >  What to do if Centos crontab does not execute

What to do if Centos crontab does not execute

angryTom
angryTomOriginal
2020-03-17 13:03:184429browse

What to do if Centos crontab does not execute

What to do if Centos crontab does not execute

The steps to troubleshoot the cause are as follows:

1. First, confirm whether the server has enabled timing Task planning service, only the root user can open and close the crond service

[root@mimvp-bj script]# service crond status
crond is stopped

2. Turn on the scheduled task planning service

[root@mimvp-bj script]# service crond start
Starting crond:                   [  OK  ]

3. Check the status of the scheduled task planning service (recommended learning : navicat tutorial)

[root@mimvp-bj script]# service crond status
crond (pid  24577) is running…

4. Check the crontab output log and troubleshoot

cat /var/spool/cron/root # root用户就是root文件

5. Check the crontab task format. If the format is incorrect, it is not correct. Will execute

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# .—————- minute (0 – 59) 
# |  .————- hour (0 – 23)
# |  |  .———- day of month (1 – 31)
# |  |  |  .——- month (1 – 12) OR jan,feb,mar,apr … 
# |  |  |  |  .—- day of week (0 – 6) (Sunday=0 or 7)  OR
#sun,mon,tue,wed,thu,fri,sat 
# |  |  |  |  |
# m h dom mon dow command
# *  *  *  *  *  command will be executed

For example:

*/5 * * * * root /usr/libexec/atrun

Parameter explanation:

minute(m)   :  代表一小时内的第几分,范围 0-59。 
hour (h)   :  代表一天中的第几小时,范围 0-23。 
mday (dom)  :  代表一个月中的第几天,范围 1-31。 
month (mon)  :  代表一年中第几个月,范围 1-12。 
wday  dow)   :  代表星期几,范围 0-7 (0及7都是星期天)。 
who            :  要使用什么身份执行该指令,当您使用 crontab -e 时,不必加此字段。 
command(command): 所要执行的指令。

This article comes from PHP Chinese website, CentOS usage tutorial column, please pay attention to this column for more related tutorials!

The above is the detailed content of What to do if Centos crontab does not execute. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn