Attention

This is an outdated article and only applicable for LPagery versions BEFORE 2.0. For our updated and improved knowledge base click here -> 

How to Set Up a Reliable Cron System for WordPress

Running WordPress Cron Jobs Without Timeouts #

Running WordPress cron jobs without being affected by timeouts can be crucial for ensuring that scheduled tasks, such as publishing posts or performing updates, are executed reliably. The built-in WordPress cron system relies on web requests, and it can be affected by various factors, including server timeouts. To address this, you can use an alternative method to trigger WordPress cron jobs.

Step-by-Step Guide on Setting Up a Reliable Cron System for WordPress #

1. Disable the Default WordPress Cron #

In your wp-config.php file, add the following line to disable the default WordPress cron:

define('DISABLE_WP_CRON', true);

This prevents WordPress from running its cron jobs on every page load.

2. Set up a Server Cron Job #

Use your server’s cron job functionality to trigger the WordPress cron at regular intervals. This involves adding a cron job entry that calls the WordPress cron script. Open your server’s crontab file:

crontab -e

Add a line like the following to run the cron every 5 minutes:

*/5 * * * * php /path/to/your/wordpress/installation/wp-cron.php >/dev/null 2>&1

Replace “/path/to/your/wordpress/installation” with the actual path to your WordPress installation.

3. Consider Using an External Cron Service #

An alternative to the server cron jobs is to use an external cron service. External cron services are third-party platforms that automate scheduled tasks without relying on your server’s built-in cron functionality. We recommend using EasyCron.

Here’s how they work:

  • Locate the Cron URL: Usually the Cron-URL is the following: https://my-domain.com/wp-cron.php. You can find the Cron-URL in the History-Area of LPagery when viewing the Google Sheet Sync Settings of an entry.
  • Configure External Cron Service: Access the dashboard or interface of the chosen external cron service. Create a new cron job and paste the cron URL into the appropriate field. Configure the desired frequency and timing for the cron job on the external service.
  • Save and Test: Save the configuration in the external cron service. Test the cron job manually to ensure that it triggers the execution of the wordpress cron-jobs.
  • Monitoring and Notifications: Set up any monitoring or notification preferences within the external cron service to stay informed about job executions.
  • Review Logs (if available): If the external cron service provides logs, users can review them to ensure that the cron job is running as expected.

4. Increase PHP Execution Time #

If your cron jobs are particularly resource-intensive, you may need to increase the maximum execution time for PHP scripts in your php.ini file. Look for the max_execution_time directive and adjust it as needed.

max_execution_time = 300

The above example sets the maximum execution time to 300 seconds (5 minutes).

By setting up a server cron job and disabling the default WordPress cron, you can ensure that your scheduled tasks are triggered at regular intervals without being affected by page load timeouts.

Where should we send your exclusive 7-day free trial + setup link?

This email contains all the details, setup guide and a link to start your 7-day trial to your inbox, so you can check it out on desktop.

The free trial is only available via this email or the page you are on!

Just Launched: Our AI Rank Tracker Your Competitors Already Show Up in ChatGPT…
Do You?
Pro Feature

When to Use This Feature

Use Examples