Having issues with your WordPress website? Something not working as it should? WordPress and a lot of plugins depend on WordPress cron job, so that should be your first suspect.
This article will tell you all you need to know about WordPress cron jobs and how to troubleshoot them.
Let’s dive straight in, starting with the fundamental question:
What is a WordPress cron job?
A cron job, also known as cron or crontab, is a function from the Linux and Unix world. A cron job is a repetitive or scheduled task that executes a script or program frequently. It has a very powerful scheduler with lots of frequencies to set. For example, you can prepare a job for every minute, twice an hour, on a specific day(s) of the month, or similar. A cron job usually runs on the server-side. WordPress comes with a unique solution to run cron jobs that do not need to be set on the server-side.
Why use WordPress cron jobs?
WordPress is a CMS system, and many functions/tasks need to be run on a scheduled basis. You can make a post and prepare it to go online at a specific time . The core WordPress installation has many other tasks to run regularly. Plugins depend on cron jobs as well.
For example, the WP Spotlight plugin fetches Instagram posts and places them on the website every hour by default. You can change this frequency in the plugin settings. The plugin itself creates a cron job.
Why do I need to know about WordPress cron jobs?
Let’s take the example of Instagram posts. If no new posts appear on your website, the most likely reason could be that the cron job is not working. Understanding the basics of WordPress cron job helps to identify the problem.
How does the WordPress cron job work?
The WordPress core installation includes a PHP script called wp-cron.php. Whenever someone visits your website or accesses the dashboard, the script is triggered and all the cron jobs are executed. For most websites, this is fine. But if your website has very few visitors , the cron jobs will run very infrequently. For websites with heavy traffic, cron jobs get triggered a lot and might cause performance issues resulting in a website slowdown.
How can I control WordPress cron jobs?
To avoid performance issues you can disable the cron jobs in WordPress and configure it on the server-side. To do that you need to login to your hosting portal and configure the cron jobs. Evey good hosting company has a how-to article on this. Click here to see the how-to for Namehero. Namehero uses the Cpanel dashboard. CPanel is relatively standard, so this article should apply to most websites.
How do I confirm my WordPress cron jobs are working?
Unfortunately, this is not possible in the standard WordPress. You will need to install a plugin. I recommend WP Control (screenshot). After installation, under tools, cron events, you can see all the cron jobs. The column “next run” gives you an indication about the health. There should be no jobs with a date in the past visible. If there are any, it means cron jobs are not working and you need to look into it.
How do I check it?
First of all, go to your hosting dashboard and check in the file manager if the file wp-cron.php is there.
Second open/edit the wp-config.php file in the file manager.
Check for the statement.
If present in the wp-config.php, it means WordPress cron jobs are disabled. Change “true” to “false” or delete the statement to enable WordPress cron jobs.
In fact, this the statement you would need to insert in wp-config.php if you prefer to run cron jobs server-side.
If both steps above are looking fine (wp-cron.php present, cron job not disabled in wp-config.php), then a plugin will most likely conflict with the cron jobs.
Do you have a cache or security plugin installed? If yes, disable first the cache plugin and then check again under tools, cron events. There is a refresh button, and you will notice immediately if the last run column updates. If not, continue and disable the security plugin if installed.
Once you have identified which plugin is the culprit, the best thing to do is to delete it and any related settings and making sure they are removed from the database. You can then reinstall the plugin and start fresh.
Did this article help you resolve your problem? Please visit my Facebook page and get in touch with me.
How to keep attackers away from your WordPress. Read my blog secure WordPress
Please let me know if this article was helpful and use the comment section below. Thank you!
Check out my blog page
To stay up to date with the homelab hardware and software I use, I’ve decided to blog about what I use and how it has helped me.
That being said, homelabs are definitely worth investing in if you want to learn more about virtualization, networking, storage, and clustering or just get your feet wet with some home projects like playing around with applications. I also host my WordPress website at home with my Dell Poweredge server.
Homelabs provide a place where everyone can play around with different configurations without actually affecting real-life production. If homelab hardware breaks or fails, it’s not really a big deal since nobody is running their business on it!