Knowledge Base
Task scheduling: WP-Cron vs. system cron
WordPress core and many plugins are dependent on a scheduling system to perform time-based tasks.
Scheduled tasks can be run in two ways:
WP-Cron
System cron
WP-Cron:
Pros:
- WordPress keeps user in WordPress (familiar) environment.
API is much simpler to set up. - WP-Cron puts tasks into queue to run at next opportunity (next page load.) i.e. task scheduled for 2 pm doesn't run due to no page activity at 2 PM but will run eventually, on next page load.
System cron doesn't queue tasks. If task doesn't run at scheduled time no repeat runs will be attempted. - Access to system cron may not be available through host provider.
Eg. host is using shared infrastructure and denies access to system cron for security reasons.
nb: pretty sure there is a workaround for this. Cron config allocatd per user, located in user home, runs system cron using user's config under restricted permissions. - WordPress API is much simpler to set up and keeps user within WordPress environment.
System cron on the other hand involves going to command line level (leaving WordPress environ.), and having familiarity with cron params and format used in setting up scheduled tasks.
Cons:
- Page load dependent. Wp-Cron triggers scheduled tasks only on a page load.
Eg. Task is set up to run at 2 pm but has page activity occurs until until 5 pm so task runs at 5 PM. WP-Cron, in the meanwhile, throws an error to indicate scheduled tasks did not run. - System cron not as user friendly as WP-Cron. System cron config is done at CLI level by editing a cron config file. Must use cron params in correct format to set up triggered tasks.