How to find and remove hanging Magento cron jobs with SSH

How to find and remove hanging Magento cron jobs with SSH

Problem

Magento cron jobs will occasionally freeze. You may notice the cron job has failed to run at its designated time or times, or you may receive notification of a cron job failing to run when you log in as an administrator.

Solution

The following procedure outlines how to use SSH to confirm a hanging cron job and how to flush it so it can run as scheduled. However, if your cron consistently hangs, this suggests a larger issue and you should contact the Nexcess Support Team for assistance.

  1. Log in to your account using SSH.

  2. Run the following command to locate hanging cron jobs:

    <username>@sip4-000 ~]$ ps ufx | grep cron

  3. The output should resemble output shown below:

    root 12080 0.0 0.0 117328 460 ? Ss Mar25 5:23 crond
    username 26529 0.0 0.0 103244 848 pts/0 S+ 22:33 0:00 \_ grep cron
    username 6876 5.0 0.3 646760 88476 ? S 15:42 20:50 /usr/bin/php /chroot/home/username/domainname.com/html/cron.php -mdefault

      • The first line shows the cron service running on the server.
      • The second line shows the command that you just ran. It matches itself when looking for the word "cron" in the running services.
      • Most importantly, the third line shows your Magento cron job. The cron job usually runs quickly, so if it shows up here, it is likely hanging.
      • You can confirm a hanging cron job by checking the second column from the right. The 15:42 20:50 shows the duration of the cron job; if this duration takes longer than an hour, then it is hanging. 

  4. To stop the cron from running, kill the command by referencing the PID. Returning to the command output, the second column from the left is the PID 6876.

  5. Run the following command to terminate the command:

    [username@sip4-000 ~]$ kill -9 6876

  6. You may now run the ps ufx | grep cron command to confirm the Magento cron job is no longer running. Your Magento cron job will now continue as scheduled.

 

For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (1 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to configure multiple Magento storefronts
Added on Wed, Jan 30, 2019
How to improve Magento maintenance mode
Added on Wed, Jan 30, 2019
How to flush your Magento cache
Added on Tue, Jan 29, 2019
How to create dev sites for Magento 1
Added on Wed, Jan 2, 2019
How to schedule cron jobs in Nexcess Cloud
Added on Fri, Jul 6, 2018
How to remove index.php from your Magento site URL
Added on Wed, May 31, 2017
How to issue a reindex in Magento
Added on Wed, Jan 30, 2019
What is the “Client denied by server configuration app/etc/local.xml” error?
Added on Thu, Sep 10, 2015
How to change your Magento 1.x admin password
Added on Tue, Jan 29, 2019
What is Varnish?
Added on Thu, Aug 28, 2014