Skip to content

Knowledgebase

Replacing visitor-triggered WordPress cron with a scheduled task

wordpress, performance

A scheduled hosting task can trigger WordPress background work at regular intervals instead of waiting for visitor traffic. Configure and verify the replacement before disabling the normal trigger, and choose an interval appropriate to the site's workload and plan.

01 Check the current arrangement

Confirm whether the service or a management tool already runs WordPress cron. Adding another runner without checking can create duplicate or overlapping work. Review the required timing for scheduled posts, emails and commerce jobs.

Identify the correct installation path, hosting user and supported PHP or WP-CLI executable. A command that works in an interactive shell may use a different environment from the scheduler.

02 Create and test the replacement

  1. Choose one supported method: a scheduled HTTPS request to wp-cron.php or an appropriate command-line runner.
  2. Configure the task through the service's scheduled-task interface using the actual paths and a reviewed interval.
  3. Retain useful output or error reporting during initial testing rather than discarding every failure.
  4. Run a controlled test and inspect the event list and logs to confirm due work is processed.
  5. Only after the replacement is verified, add or update the following setting in the correct wp-config.php:
Code or configuration example
define('DISABLE_WP_CRON', true);

03 Use a command appropriate to the environment

Where WP-CLI is supported, the relevant operation is wp cron event run --due-now --path=/path/to/wordpress, with the correct executable and installation path. This runs due callbacks and can perform real business actions, so test it deliberately. Do not copy a placeholder path into a live scheduler.

For an HTTPS trigger, confirm the request reaches WordPress without a login challenge, redirect loop or certificate error. Do not disable TLS verification to hide a routing problem.

04 Example: schedule one verified WordPress runner

For a single-site installation with authorised WP-CLI, local flock and an approved five-minute interval, a scheduler entry can look like this. Replace the interpreter, account and private paths with the service’s real values before enabling it.

Code or configuration example
*/5 * * * * /usr/bin/flock --nonblock /home/ACCOUNT/private/wp-cron.lock /usr/local/bin/wp --path=/home/ACCOUNT/sites/example.com --url=https://example.com cron event run --due-now >> /home/ACCOUNT/private/wp-cron.log 2>&1

Due events execute real callbacks, so first verify this arrangement with a controlled staging task and check for an existing managed runner. The local lock prevents this launch path from overlapping itself; it does not coordinate other servers. Keep useful logs while testing.

Expected result: Due work completes at the intended interval without competing copies. Only after the replacement is confirmed should the normal visitor-trigger setting be disabled. A failed replacement has a documented route back to the previous working scheduler.

How do I prevent duplicate or overlapping cron runners?

Choose an interval longer than the normal execution time or use an appropriate supported locking approach when needed. Heavy jobs should not accumulate faster than the site can process them. Review errors and overdue events over several intervals.

A command-line runner can use a different PHP configuration from the web application, so confirm required extensions and compatibility. On Multisite, plan the site scope rather than assuming one command covers every network queue as intended.

05 Verify and reverse safely

Test a scheduled post or other controlled workflow and confirm its actual result. If the replacement fails, restore the intended default trigger while correcting the job, and remove obsolete duplicate scheduler entries.

Document the owner, interval, command location and monitoring route. Disabling visitor-triggered cron without a functioning replacement can silently stop publication, notifications and maintenance, even though ordinary pages continue to load.

Was this answer helpful?

Need a little more help?

Our support team can help you find the next step.

Contact support

Powered by WHMCompleteSolution