What is a cron?
The cron deamon is a timebased service that starts processes. In web development that's often a php script. A cronjob repeats periodically.
WordPress has its own cron system implementation. It works right after installation and does not need any additional server configuration. It sends a HTTP request on every page request of your website to wp-cron.php and executes scheduled events of the core and plugins. This way planned posts are published, system updates are received and pingbacks are triggered for example.
This implementation of wp-cron has a good reason. WordPress is the most popular CMS with a market share of round about 50% (58% w3techs.com, 44% in Germany www.cmscrawler.com May 2017). Many of those websites are from none professional bloggers that are not able or do not want to afford professional hosting. Most of the cheap hosters don't support cronjobs so an own implementation makes wordpress fully functional even on cheap hostings.
Disadvantages of wp-cron
The pseudo WordPress cron has some serious disadvantages and should be replaced by a real cronjob if possible.
First of all it's not dependable. If there is no traffic on your website no process will be started. This means no planned posts, no system updates, no pingbacks and no other scheduled processes are triggerd. There will be no cron function at all.
On websites with traffic it stresses the server performance because all incoming requests are doubled and there are requests to the database for some cron lock variables at least. That's no expensive operation but if you use ajax on your website for example this can cause at lot of unnecessary work for the server.
Last of all it's not the job of a visitor to trigger any scheduled process that has probably nothing to do with his or her intention of visit. That's the job of a real cronjob!
How to config a real cronjob?
Step one: Disable the HTTP requests to wp-cron.php. Define the constant DISABLE_WP_CRON to your wp-config.php.
Step two: create a real cronjob for triggering the wp-cron.php. This can be done with a configuration wizzard on your hosters admin panel or if you have ssh access to your server you can add this line to crontab for example.
0 * * * * wget http://domain.tld/wp-cron.php
0 * * * * php /path/to/docroot/wp-cron.php > /dev/null 2>&1
For multisite intallations use wp-cli.
* * * * wp cron event run --path=/path/to/docroot --url=www.domain-of-site.tld --due-now
Or you can use our WordPress cron service.
What does it do?
- Publishs planned posts
- Check updates for core, themes and plugins
- Whatever your plugins want to do by scheduled events
- Not dependable
- Server performance suffers
- It's not your visitors job