Triggering cron by calling wp-cron.php on the command line rather than with wget?

Looking at the file documentation inside wp-cron.php it seems it’s absolutely possible to just call $ php wp-cron.php:

/**
 * A pseudo-CRON daemon for scheduling WordPress tasks
 *
 * WP Cron is triggered when the site receives a visit. In the scenario
 * where a site may not receive enough visits to execute scheduled tasks
 * in a timely manner, this file can be called directly or via a server
 * CRON daemon for X number of times.
 *
 * Defining DISABLE_WP_CRON as true and calling this file directly are
 * mutually exclusive and the latter does not rely on the former to work.
 *
 * The HTTP request to this file will not slow down the visitor who happens to
 * visit when the cron job is needed to run.
 *
 * @package WordPress
 */

What else you can do on the command line, is to use wp-cli for that.

$ cd /path/to/wordpress
$ wp cron event run --due-now

To force-trigger one single cron independent from its set schedule run:

$ wp cron event run my_custom_cron_event

Or as a one-liner to be used in a crontab to run every full hour + 15 minutes (2:15 pm, 3:15pm, 4:15pm etc.):

15 * * * * cd /path/to/wordpress && wp cron event run --due-now > /dev/null 2>&1

Leave a Comment