Answer the question
In order to leave comments, you need to log in
Why does cron run a task so often?
I set a python script to run every two hours. Each script execution is logged and judging by the logs, it was executed 155 times in the last 20 hours. What is the problem?
Here is the content of /etc/crontab (script /root/PCP-AUTO/cron_file.py ):
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --repo$
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --repo$
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --repo$
* 2 * * * root /usr/bin/python3 /root/PCP-AUTO/cron_file.py
#
Answer the question
In order to leave comments, you need to log in
* 2 * * *
Means to execute the script every minute when the hour is two (2:00 AM, 2:01 AM, ..., 2:59 AM)
Every two hours, it's something like this:0 */2 * * *
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question