You are here

Drush Cron Already Running Issue

#Fix Cron Already Running Problem
#please replace ?text? appropriately

#log in to mysql from terminal:
mysql -u ?dbusername? -p

#Sequential mysql commands to fix:
------------------------------------
mysql> show databases;
mysql> use ?dbname?;
mysql> DELETE FROM `variable` WHERE name = 'cron_semaphore';
mysql> DELETE FROM `variable` WHERE name = 'cron_last';
mysql> exit
---------------------------------------------------

drush cc all

#Test
drush cron

Cron may have been interrupted during execution, such as by a server restart. This can result in watchdog (error) messages like "Attempting to re-run cron while it is already running" and "Cron has been running for more than an hour and is most likely stuck". Try resetting the semaphore and deleting the "last run" timestamp from the database. (Note: deleting the "last run" timestamp will cause your Status report to indicate that cron has never run.) You can do so with this SQL...

USE Name_Of_Your_Drupal_Database;
DELETE FROM variable WHERE name="cron_semaphore";
DELETE FROM variable WHERE name="cron_last";

... or with drush (Drupal7):

drush vdel cron_semaphore
drush vdel cron_last
drush sqlq "DELETE FROM semaphore WHERE name = 'cron';"

... For drush with Drupal8:

drush php-eval "\Drupal::lock()->release('cron');"
code type: