

I mentioned above the Site Health pages within WordPress. The important final step is to make sure it’s all working as expected. The remainder of the script is a loop calling the wp cron event run command for each of those tasks individually.
#PLESK CRON JOB INSTALL#
On a basic install of WordPress, it might return wp_version_check wp_update_plugins wp_update_themes if those three tasks are ready to be run. The portion of the script wp cron event list -next_run_relative=now -fields=hook -format=ids gets a list of events ready to be run and returns them in a space separated format. The script becomes: cd /path/to/site įor hook in $(wp cron event list -next_run_relative=now -fields=hook -format=ids) On the downside, the command is a little more complicated. It also prevents a fatal error in one of your events from preventing other events from running. If you have long running cron events in WordPress, the safest approach to running these is to run each task in its own process. Wp cron event run -due-now Allowing for long running tasks The simplest approach is to run the following command as the cron job. This is a requirement for the modern approach to running cron. Many hosting providers include WP-CLI as a standard feature, especially those providing specialist WordPress hosting. The modern approachįor the uninitiated, WP-CLI allows site owners to manipulate WordPress via the command line: you can modify posts, for example, but importantly you can also run cron events. For popular web hosting dashboards view cPanel’s cron job documentation or Plesk’s cron job documentation. Setting up a cron job differs depending on your web hosting provider, there is no one size fits all instruction available. I recommend you configure your server to run real cron tasks every ten minutes to ensure you don’t get incorrect reports of errors in the WordPress dashboard. A cron job is considered late if it hasn’t run within 15 minutes of the scheduled time, and failed if it hasn’t run within one hour of the scheduled time. This is done by adding a directive to the wp-config.php file: define( 'DISABLE_WP_CRON', true ) ĭisabling WordPress’s native cron instructs the Site Health Check feature to relax some of the rules around when a cron job is considered late or failed. To configure WordPress to use real cron jobs requires disabling the faux cron jobs WordPress uses natively. More problematically, if your site is behind a username and password, using wp-cron.php may fail to run in certain server configurations. It runs each event as request to your web server which means long running tasks may time out before they are complete. In the days before the WordPress CLI (WP-CLI), using the wp-cron.php file was the only technique available to site owners wishing to use real cron events.Īs WordPress doesn’t use real cron with wp-cron.php, using the file has some limitations.

For WordPress site owners wishing to use real cron via a crontab job, it’s fairly common to see advice to use curl to request the site’s wp-cron.php file on a regular basis.
