brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: WP_CRON_LOCK_TIMEOUT sets the minimum gap between WordPress cron runs

WordPress
~/tips/tip-wordpress-wp-cron-lock-timeout

define( 'WP_CRON_LOCK_TIMEOUT', 60 );

A wp-config.php constant that stops a cron process from starting again within a set number of seconds.

WP-Cron has a habit of getting its own tips: disable it, move it to a real cron job, trigger it by hand. The setting that sits quietly in the docs is the lock timeout, and it’s about overlap.

define( 'WP_CRON_LOCK_TIMEOUT', 60 );

The documentation describes it as making sure a cron process cannot run more than once every WP_CRON_LOCK_TIMEOUT seconds. In the example it’s 60. Put it in wp-config.php, above the line that says to stop editing.

Why would I care? On a busy site, many visitors arrive at the same moment, and WordPress checks on page loads whether scheduled work is due. A lock that lasts longer makes it less likely that a second process starts the same batch while the first one is still busy. That reasoning is mine, not the docs’: they only state the rule above. So treat the number as something to adjust to how long your slowest scheduled task takes.

This constant sits next to DISABLE_WP_CRON in the same docs section. That one switches the built-in cron off completely, and you’d then run wp-cron.php from a system cron job yourself. If you do that, the lock timeout matters much less, since only one caller is left.

Caveats: the docs don’t give a default value for the lock, so don’t assume what you get without the line. By the same logic a long timeout can delay the next run, which is my inference and not something the docs say. Keep the number modest and watch how your tasks behave.

Further reading: Editing wp-config.php

Going deeper: Guide: find out why a Linux service failed, with journalctl

More WordPress tips curl -s "https://example.com/wp-json/wp/v2/posts/42?_embed" curl -s -D – -o /dev/null "https://example.com/wp-json/wp/v2/posts?per_page=100" curl -s "https://example.com/?rest_route=/" 'You must be logged in.', add_filter( 'the_title', 'plugin_shout_title', 20 ); All WordPress tips (92) All topics

Link