What is a Cron Job?
Cron Jobs are basically scheduled tasks that are created automatically by WordPress or a WordPress Plugin that you have activated on your website. They are similar to an alarm clock that goes off regularly to trigger an automative response.
Before we delve into explaining how you can view and control Cron Jobs that are running on your WordPress website, for those new to this term it’s best we first explain what a ‘Cron Job’ actually is. In short, the term Cron Job refers to the list of schedules set at intervals that are undertaken each and every day on a website. A ‘Cron Job’ is always a repetitive task that is run at set duration apart. For the most part, a Cron Job is ran once in a 24 hour period although some occur more frequently (as needed).
Many WordPress plugins, especially those that trigger emails to be sent out will automatically configure Cron Jobs when you click the install and activate buttons. You will generally never need to worry about when the Cron Job will occur unless you run into an issue. While we will discuss how to view and delete ‘Cron Jobs’ on your WordPress website later on in this tutorial, for the most part, you will have no need to delve into ‘Cron Jobs’ unless the job has duplicated itself or isn’t running at all.
To be more specific, some ‘Cron Jobs’ undertaken on a website that you may need to troubleshoot include:
- Scheduled Backups
- Maintenance Tasks
- Disk Space Monitoring
- Deletion of Files
- Sending of Emails
When you view the list of Cron Jobs running on your website, at first you may be taken back if you are not a developer. Every ‘Cron Job’ has a script which is the task to be executed, a command that executes the script and an action of the script. No ‘Cron Job’ should run more often than every 15 minutes unless you have a dedicated server.
In terms of when a Cron Job runs, they can be set to run at the following periods apart:
- Minutes
- Hours
- A Certain Day of the Week
- A Certain Day of the Month
While many plugins do create a Cron Job, having excessive amounts of ‘Cron Jobs’ running can slow down your server. It is for this reason that we always advice limiting the amount of plugins on your website to those that you need rather than want.
Why Would I Need to View my Cron Jobs?
While many users of WordPress will never have a need to view their Cron Jobs, we’ve had a handful of customers who have needed to look at this. So we’ve decided to create a step by step tutorial to help those that run into a Cron Job related problem either with one of our plugins or another WordPress plugin.
If you have a fresh WordPress install and you are yet to install a plugin you may think that there are no ‘Cron Jobs’ running. This is incorrect as WordPress runs a number of Crons such as one that ensures updates are displayed, old trashed comments are deleted and scheduled posts are published.
For some WordPress users, they may find that a specific set of ‘Cron Jobs’ ran by a plugin are slowing down their website, or they may presume this is the case. Viewing the ‘Cron Jobs’ will allow the WordPress user to delete the plugin and find an alternative solution or delete off ‘Cron Jobs’ that they do not require on their website. Other WordPress users may find that an email is being sent twice in a 24 hour period whereas it should only be sent once. This is generally caused by a duplicate ‘Cron Job’ that can be fixed by removing one of the jobs from the task list.
Errors that Relate to WordPress Cron Jobs
If you have run into an error on your WordPress site that is related to an automated regular task, a Cron Job could be at fault. Perhaps the Cron Job was never created properly on the installation of a plugin, or worse, perhaps a duplicate was created. Some of the following errors may occur if there are problems with Cron Jobs on your website:
- A duplicate of an event occurs. For example, an email that is supposed to be sent 10 days before a “member’s account expires” is sent twice within a 24 hour period or a number of posts are published twice leading to SEO related issues.
- A scheduled post is not published
- An automated backup or cleanup does not occur
- Any type of automatic task may fail
Viewing and Controlling Cron Jobs Video Tutorial
How Can I View and Edit my Cron Jobs?
The easiest way to view your Cron Jobs and alter or delete a job is through the use of a well-known plugin: WP Crontrol. It is a well developed Cron Job plugin currently available from WordPress.org repository. If you do not find this plugin to be the right fit, there are a number of other free Cron Job control related plugins available.
When you install WP Crontrol, or a similar plugin for WordPress, you will be able to view all scheduled ‘Cron Jobs’. The hook name of each ‘Cron Job’ gives you an insight into what that ‘Cron Job’ is designed to do. In the next column, the time at which the next ‘Cron Job’ will occur and the time interval between each are displayed. Each ‘Cron Job’ can be edited or deleted which allows you to remove a duplicate if you have ran into this type of issue. While deleting a duplicate ‘Cron Job’ for a plugin you have installed is entirely fine, be sure to never delete a standard WordPress ‘Cron Job’ as this will cause failures with basic WordPress functionality and actions.
- Log into your WordPress website as an admin and install WP Crontrol. This can be installed directly from your WordPress dashboard.
- ‘Activate‘ the WP Crontrol plugin.
- From your WordPress dashboard, click on the ‘Tools‘ menu. Choose the ‘Cron Events‘ tab.
- From here, you should be able to see all of the ‘Cron Jobs‘ occurring on your WordPress website. Each ‘Cron Job’ is displayed in a separate row, with each having their own ‘Delete‘ option. Always double check before deleting a ‘Cron Job’.
The ‘Hook Name’ of the Cron Job generally gives insight into which plugin has created it. Those starting with ‘wp’ are generally created by WordPress rather than a plugin. It is advised you do not delete these Cron Jobs.
While WP Crontrol is a useful plugin if you need to delete a duplicate action or an action you don’t necessary need, you can also do the following using this free WordPress plugin:
- Add a new Cron event
- Run a Cron event immediately
- Edit a Cron event
The post How to View and Control WordPress Cron Jobs appeared first on Tips and Tricks HQ.
No comments:
Post a Comment