How to Check if WordPress Cron is Working

Navigate This Document

How to Check if WordPress Cron is Working

WordPress uses a system called WP-Cron to handle scheduled tasks such as publishing scheduled posts, checking for updates, and other time-based activities. Ensuring that WP-Cron is working properly is crucial for maintaining the smooth operation of your WordPress site. Here’s how you can check if WordPress Cron is working.

Method 1: Check Scheduled Tasks Using a Plugin

  1. Install a Cron Manager Plugin
    • Go to your WordPress dashboard.
    • Navigate to Plugins > Add New.
    • Search for “WP Crontrol”.
    • Click Install Now and then Activate.
  2. View Scheduled Tasks
    • After activation, navigate to Tools > Cron Events.
    • This will display a list of all scheduled cron events.
    • Check the list to see if tasks are scheduled and their next run time. If tasks appear and have future scheduled times, WP-Cron is likely working.
  3. Inspect Cron Events
    • Look for events with names such as wp_update_plugins, wp_update_themes, and other WordPress core or plugin-related tasks.
    • Ensure that there are no errors or missed schedules.

Method 2: Check Cron Jobs via wp-config.php

  1. Enable WP-Cron Logging
    • Edit your wp-config.php file by adding the following lines before the /* That’s all, stop editing! Happy publishing. */ line:
      define('ALTERNATE_WP_CRON', true);
      define('WP_DEBUG', true);
      define('WP_DEBUG_LOG', true);
  2. Trigger WP-Cron Manually
    • Visit https://yourdomain.com/wp-cron.php?doing_wp_cron in your browser. Replace yourdomain.com with your actual domain.
    • This URL manually triggers the WP-Cron system.
  3. Check the Debug Log
    • Go to wp-content directory via FTP or your hosting file manager.
    • Open the debug.log file.
    • Look for any entries related to WP-Cron. If there are errors, you might need to address these to get WP-Cron working properly.

Method 3: Use Command Line (WP-CLI)

  1. Install WP-CLI
    • Ensure WP-CLI is installed on your server. You can find installation instructions on the WP-CLI website.
  2. List Scheduled Cron Events
    • Open your terminal or SSH into your server.
    • Navigate to your WordPress directory.
    • Run the following command:
      wp cron event list
    • This will list all scheduled cron events. Verify that events are listed with future scheduled times.

Method 4: Verify Cron with Server Logs

  1. Check Server Access Logs
    • Access your server’s access logs. This can usually be done through your hosting control panel or via SSH.
    • Look for entries involving wp-cron.php. For example:
      [date] "GET /wp-cron.php?doing_wp_cron=timestamp HTTP/1.1" 200
    • Frequent entries indicate that WP-Cron is being triggered regularly.
  2. Review Error Logs
    • Check your server’s error logs for any issues related to WP-Cron.
    • If there are no errors, it indicates that WP-Cron is functioning correctly.

Common Issues and Troubleshooting

  • Cache Plugins: Sometimes, cache plugins can interfere with WP-Cron. Try disabling your cache plugin temporarily to see if it resolves the issue.
  • Hosting Environment: Some web hosts disable WP-Cron by default and recommend setting up a real cron job. Check with your hosting provider.
  • Low Traffic: WP-Cron relies on site traffic to trigger. If your site has low traffic, consider setting up a real cron job on your server.

Setting Up a Real Cron Job

If WP-Cron is not reliable on your hosting environment, you can set up a real cron job to trigger wp-cron.php.

  1. Disable WP-Cron
    • Add the following line to your wp-config.php file to disable the default WP-Cron:
      define('DISABLE_WP_CRON', true);
  2. Create a Server Cron Job
    • Log in to your hosting control panel or SSH into your server.
    • Set up a cron job to call wp-cron.php every 5 minutes:
      */5 * * * * wget -q -O - 'https://yourdomain.com/wp-cron.php?doing_wp_cron' >/dev/null 2>&
    • Replace yourdomain.com with your actual domain.

By following these steps, you can ensure that your WordPress cron system is functioning correctly and troubleshoot any issues that may arise.