Question

Is there a way to execute a WordPress action/hook from a server-side CRON job?

I'm not talking about WordPress cron tasks...

Was it helpful?

Solution

Typically you schedule an event (action/hook) using:

wp_schedule_event($timestamp, $recurrence, $hook, $args);

Then to execute it using a server-side CRON , you would load WordPress's wp-cron.php.

This can be problematic because WP has it's own internal (not-real) Cron, so it's best to disable it completely using define(‘DISABLE_WP_CRON’, true); to avoid conflicts.

There are lots of articles on this you can read by searching for "Replacing WordPress cron" or "Using real cron with WordPress", so you know what you're in for (for example you can also lock the cron).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top