If you are familiar with the UNIX system, then you must have heard about Crontab or Cron.
It’s nothing but a UNIX command that is used to schedule a specific task that you need to carry out in near future.
That can be truly handy in some cases where you need to do some specific work at a specific time of the day.
All you need to do is use Cron to set up the time for running that code or may be any task and it will work the way you want it and on the time that you wish to run it.
WordPress Cron is similar to this but the difference is that it can be only used for WordPress.
But do remember that every single server that can host WordPress is different from one and another and hence, it’s absolutely problematic to implement a specific set of commands that can work on pretty much every single server.
This is the reason why WordPress Cron jobs do not work like that. They are not synchronized to any server clock or any clock for that matter.
They get triggered on certain activities, for example a user visiting a particular page or may be a post or availing a particular service.
So, each and every time there is a visitor to a particular page, WordPress will check for any type of cron job that needs to be carried out or not.
But if it gets implemented this way, then there will be an obvious issue with the cron jobs.
For websites that do not have a lot of visitors, the cron jobs might never get the chance to run.
So is it good for large WordPress sites?
Well, as you can understand using WordPress cron jobs are not the best thing to go with if you have a low traffic website, now it’s time to understand whether you can use it if you have a very popular website.
Well, cron jobs are called as and when there is a visitor to a particular post or page, so if you have a high traffic website it is most likely that the particular page or post will have lot of visitors at a time.
That means your scheduled process will get triggered every time someone visits the page or the post. In this kind of situation, most likely your server will crash because of the multiple requests to same process.
Unless you have a dedicate server for your WordPress website, it’s unlikely that your server will survive this kind of situation.
So, the point is whether you have a site with high traffic or low traffic, using WordPress cron jobs might turn out to be problematic for you to deal with.
Now that you have idea about cron jobs, it’s time that you learn to view and control them so that they work the way you want.
Working with WordPress Cron System
To get going, you need to install WP Crontrol plugin. You can get this plugin from the plugin finder on your WordPress.
Once installed, you will have to activate the plugin.
Now go to your “Dashboard “then “Tools” and go to “Cron Events”.
This page will allow you to view all the cron events and the settings that you wish to control.
The page is basically a list of cron events that are scheduled on your WordPress server to run.
These cron jobs are scheduled by the WP cron system. The first column of the list gives you the hook name, or to be specific, the event that makes the cron job run.
Mostly the hooks will start with a prefix wp_, for example wp_update_plugin or may be wp_update_theme, etc.
As you can understand, the hook names are indicative of the event that the cron job controls.
In case you have other plugins installed on your WordPress and they have their own cron jobs, the prefix to the hook names will be different in that case.
The list will also tell you the next scheduled run time of a particular cron job and the time gap between two consecutive runs of that particular cron job.
The very last column of the list is the one that will allow you to delete, edit, or run a specific cron job.
But remember that deleting a system cron job might be problematic and unless you understand it well, you may not tamper with it at all.
To edit a particular cron job, you need to click on Edit right beside that particular cron job. It will let you modify the cron job the way you want it to function.
You can even change the time interval of that specific cron job along with other settings.
Once you are done with the changes, you can save the cron job to store your edited settings.
This is pretty much how you can view and edit cron jobs on WordPress.
Although it’s not necessary to add a cron job of your own, with this particular plugin adding a new cron job to the scheduler is really easy.
All you need to do is go to the Cron Jobs page and find the button that says “Add Cron Event”. This should be right at the bottom of your list page.
To create a new cron job, you need to specify hook name different from the others that are running already.
While creating a hook name, make sure to avoid any spaces and special characters. You have to provide the required arguments to run the cron job in case you need any.
You will have to specify the next time when the cron should run. Depending on the value you put in the column, the cron event will work.
And before you save your cron job you will have to select a schedule, as in how often you wish to run your cron job.
In case you wish to run it for just once, you will have to create a non-repeating cron job. Once done, you can save your newly created cron job and it should be there on the Cron Jobs page.
So, that is all you need to know about WordPress Cron jobs and how the system works.
Make sure you understand the system well and then only start digging with the cron jobs and it should be fine.