Magento2 – Cron Jobs Stuck in Pending

croncrontabmagento-cronmagento2order-status

I currently have a problem with the cron in my Magento 2 (2.2.7 installation).

Orders are coming through but any which come through from an extension called "Adyen" are getting stuck in the "Payment Review". This has been happening periodically for a while now but this morning all of the adyen payment orders are stuck in pending and we're getting a system message reading:

You have 23 unprocessed notification(s). Please check your Cron and
visit Magento DevDocs and Adyen Docs on how to configure Cron. Last
cron check was: 08/03/2019 08:55:31

I have checked in the cron_schedule table and they seem to be getting stuck in the "pending" status as per the screenshot below:

enter image description here

I've also checked using SSH with the command: ./n98-magerun2.phar sys:cron:history | less

And there seem to be a large number of jobs with a "missed" status.

I've run the command: bin/magento cron:run several times but that has made no difference.

I also ran the following command:

username:~/httpdocs$ crontab -u username -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command


* * * * * /opt/plesk/php/7.0/bin/php /sites/website.com/httpdocs/bin/magento                                   cron:run
* * * * * /opt/plesk/php/7.0/bin/php /sites/website.com/httpdocs/update/cron                                  .php
* * * * * /opt/plesk/php/7.0/bin/php /sites/website.com/httpdocs/bin/magento                                   setup:cron:run

UPDATE

I have now checked through the cron_schedule and found a number of jobs which seem to be stuck in the "Running" status as per the screenshot below.

enter image description here

Looking across the internet at various sites it seems like this could be the problem, so I just wanted to know if this could indeed be causing the issue and if so can I simply delete the lines out of the database or is there something else I need to do?

Best Answer

Evidently we were having some other issues with the site running out of disk space, so not sure if this caused the issue.

We tidied some logs files up etc. Then went into the cron_schedule table in phpmyadmin and ran the following sql query:

DELETE FROM cron_schedule WHERE status = "running";

This seems to have resolved the issue but we will keep monitoring it just in case.

Related Topic