M
M
makar042020-03-06 09:15:21
PHP
makar04, 2020-03-06 09:15:21

Why does cron run 2 times?

Good day!
There is a Cron job wget -q -O - my-site.ru/index.php?route=common/task/doSome > /dev/null 2>&1
which should run every night at 01:15. Judging by the cron logs, it starts at 01:15:01 and runs 1 time. But the task duplicates the data and judging by my logs, the task starts at 01:15:01 and then at 01:15:02. The job executes several queries against the database and takes a little less than a second to complete.
What could be the problem? Why is data duplicated?

I'm attaching the cron logs below.

Mar 6 01:14:01 vm2002283119 CROND[8605]: (root) CMD (/usr/local/mgr5/sbin/cron-ispmgr sbin/mgrctl -m ispmgr periodic >/dev/null 2>&1)
Mar 6 01: 14:01 vm2002283119 CROND[8606]: (root) CMD ( /opt/php71/bin/php -c /usr/local/mgr5/addon/revisium_antivirus/php.ini /usr/local/mgr5/addon/revisium_antivirus/services /queue.php >> /usr/local/mgr5/var/raisp_data/log/raisp_queue.log 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[8630]: (root) CMD ( /opt/php71/bin /php -c /usr/local/mgr5/addon/revisium_antivirus/php.ini /usr/local/mgr5/addon/revisium_antivirus/services/email.php >> /usr/local/mgr5/var/raisp_data/log/email .log 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[8635]: (root) CMD (/usr/local/mgr5/sbin/cron-ispmgr sbin/mgrctl -m ispmgr problems.autosolve >/dev/null 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[8631]: (root) CMD (/usr/local/mgr5/sbin/cron-core sbin/mgrctl -m core sysinfostat >/dev/null 2>&1)
Mar 6 01: 15:01 vm2002283119 CROND[8633]: (root) CMD (/usr/local/mgr5/sbin/cron-ispmgr sbin/mgrctl -m ispmgr periodic >/dev/null 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[8632]: (root) CMD (/usr/local/mgr5/sbin/cron-core sbin/mgrctl -m core problems.autosolve >/dev/null 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[ 8634]: (root) CMD (wget -q -O - my-site.ru/index.php?route=common/task/doSome > /dev/null 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[8636]: (root) CMD ( /opt/php71/bin/php -c /usr/local/mgr5/addon/revisium_antivirus/php.ini /usr/local/mgr5/addon /revisium_antivirus/services/queue.php >> /usr/local/mgr5/var/raisp_data/log/raisp_queue.log 2>&1)
Mar 6 01:15:01 vm2002283119 CROND[8637]: (root) CMD (/usr /local/mgr5/sbin/cron-ispmgr addon/srvmon >/dev/null 2>&1)
Mar 6 01:16:01 vm2002283119 CROND[8672]: (root) CMD ( /opt/php71/bin/php -c /usr/local/mgr5/addon/revisium_antivirus/php.ini /usr/local/mgr5/addon/revisium_antivirus/services/queue.php >> /usr/local/mgr5/var/raisp_data/log/raisp_queue.log 2> &1)
Mar 6 01:16:01 vm2002283119 CROND[8673]: (root) CMD (/usr/local/mgr5/sbin/cron-ispmgr sbin/mgrctl -m ispmgr periodic >/dev/null 2>&one)
Mar 6 01:17:01 vm2002283119 CROND[8688]: (root) CMD (/usr/local/mgr5/sbin/cron-ispmgr sbin/mgrctl -m ispmgr periodic >/dev/null 2>&1)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Aborigen1020, 2020-03-06
@Aborigin1020

my-site.ru/index.php?route=common/task/doSome

aha, there is such, in your broad gull 1 time.
and judging by my logs, the task starts at 01:15:01 and then at 01:15:02.

According to your logs - you mean according to the logs of your application?
I'm afraid that the problem is not in cron, his logs confirm that he completed the task once at the set time. Cron is a very reliable tool, and most likely, the error must be looked for in your script. Let's figure it out, show a script that works incorrectly.

A
AUser0, 2020-03-06
@AUser0

Firstly, in vain you run such tasks and from under the root itself.
Secondly, according to the cron logs, the task with wget is launched one (1) time.
If it is launched twice, it means somewhere someone is launching it again.
Somewhere in some PHP script?
And third, it's worth enclosing the URL for wget in quotes:

wget -q -O - "my-site.ru/index.php?route=common/task/doSome" > /dev/null 2>&1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question