When developing plugins, you will sometimes need to execute functions on a schedule. WordPress provides such a task scheduler within the core code. In this chapter, you will learn how to schedule events, remove events from the schedule, and set custom schedule intervals. You will also learn from practice use cases.
WHAT IS CRON?
The term cron comes from the time‐based task scheduler available in Unix systems. The cron system provided in core WordPress, while named the same, is not a true cron system in that sense. It is an event scheduler. However, it doesn't run on the system at all times. Events execute only when there's a page load.
Cron in WordPress is used to schedule jobs such as checking for new versions of WordPress, checking for plugin or theme updates, and publishing scheduled posts.
How Is Cron Executed?
Unlike a Unix‐based system, cron in WordPress does not constantly run on the server, looking for jobs to execute. WordPress, and thus its cron system, runs only when an admin or front‐end page is loaded on your website. When a page is visited, WordPress will automatically check if there ...