Overview
WP-Cron is the event scheduler included with WordPress, used for performing automated tasks. Gravity Forms relies on WP-Cron for several scheduled tasks. For a full list, see the Troubleshooting Scheduled Events article.
How WP-Cron Works
WP-Cron works by triggering cron.php each time a visitor loads a page on your site. This file checks if there are any scheduled events ready to be processed, and then spawns a new request to the site’s WP-Cron endpoint (e.g., https://example.com/wp-cron.php) to process them.
Unlike a traditional server cron job, WP-Cron does not run on a fixed schedule. It is better understood as a task queue that defines a minimum time for a task to execute, rather than a precise scheduled time. A WP-Cron event will never fire before its scheduled time, but it will often fire well after it. On low-traffic sites, scheduled tasks may be delayed or missed entirely if no page load occurs at or after the scheduled time.
Delayed Processing
Because WP-Cron relies on page views to trigger scheduled event processing, this can result in some events not being processed at their scheduled intervals on sites with low traffic.
Reliability can be improved by using a real cron job or an external service to periodically contact your site’s WP-Cron endpoint (e.g., https://example.com/wp-cron.php). In both cases, you will need to disable the built-in WP-Cron trigger by adding the following line to your wp-config.php file.
define( 'DISABLE_WP_CRON', true );
Use a Real Cron Job
In hosting environments where you can access the system’s task scheduler, you can configure a cron job to run at the intervals you specify. Here are setup guides for some of the most commonly used hosts.
- Bluehost: Setup, Remove, or Edit a Cron Job
- DreamHost: Disabling WP-CRON to Improve Overall Site Performance
- GoDaddy: Create Cron Jobs
- HostGator: How to Replace WordPress Cron with a Real Cron Job
- InMotion Hosting: How to Disable the WP-Cron (wp-cron.php) in WordPress
- Kinsta: How to Disable WP-Cron (wp-cron.php) for Faster Performance
- Namecheap: What is WordPress Cron and How to Work with It
- SiteGround: How to Replace the WordPress Cron with a Real Cron Job Tutorial
- WP Engine: Event Scheduling and wp-cron
If your host is not listed above, contact them for instructions.
Use an External Service
The following services can be configured to contact your site’s WP-Cron endpoint on a schedule you define. Some services also include logging and status notifications.
Common Issues
Basic Authentication
If basic authentication is enabled, the server returns a 401 error if the cron request does not include authentication credentials. This can be resolved by adding the Authorization header to the cron request using the WordPress cron_request filter.
add_filter( 'cron_request', 'cron_request_basic_auth' );
function cron_request_basic_auth( $cron_request ) {
$cron_request['args']['headers']['Authorization'] = 'Basic ' . base64_encode( USERNAME . ':' . PASSWORD );
return $cron_request;
}
The above example is based on USERNAME and PASSWORD being constants defined elsewhere (i.e., the wp-config.php file). If not, you can include the values within the quotes, e.g. 'USERNAME:PASSWORD'.
Disclaimer: Third-party services, plugins, or code snippets that are referenced by our Support documentation or in Support Team communications are provided as suggestions only. We do not evaluate, test or officially support third-party solutions. You are wholly responsible for determining if any suggestion given is sufficient to meet the functional, security, legal, ongoing cost and support needs of your project.
Feedback, feature, and integration requests, and other functionality ideas can be submitted at https://gravity.com/feature-request/.