WordPress cron job

Are you having trouble getting your WordPress cron jobs to run on time? Working with cron jobs can be tricky for even the most experienced WordPress users. Any issues related to cron job scheduling in WordPress must be handled promptly so as not to disrupt regular operations.

To help you tackle any scheduler troubleshooting situation, I’ll discuss how to identify and fix common cron job issues within WordPress. In this comprehensive guide, you’ll learn how to diagnose and resolve common problems with running tasks within your website’s admin panel using WP-Cron or external Cron Jobs.

Let’s dive straight in, starting with the fundamental question:



What is a WP-cron system job?

A WP-cron job, also known as cron or crontab, is a function from the Linux and Unix world. A cron job is a scheduled or repetitive task frequently executing a script or program. 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.


Cyber Monday Deals

A cron job usually runs on the server side. WordPress has a unique solution to run cron jobs that do not need to be set on the server side.


Why has WordPress implemented the cron job solution?

WordPress has implemented its cron job system as a more reliable way to trigger automatic tasks. In traditional coding, it cannot be easy to coordinate when specific jobs should be run in the background without user input. A periodic cron job acts like an automated timer that goes off every once and check for any scheduled tasks that need to be run.

This automated process makes things much easier for WordPress developers and website owners who don’t have time to constantly check for updates or new content on the backend of their sites. Automated processes are also beneficial because they allow WordPress sites to stay up-to-date quickly and efficiently with minimal effort on the user’s part. Additionally, cron jobs can help save server load times, optimize content delivery and backups, and keep security measures in check by regularly scanning the site for malicious activities.

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 Social Ninja plugin fetches social feeds or reviews and places them on your website every hour. You can change this frequency in the plugin settings.

Another example is an email notification WordPress sends to an actual email address.


serpple

Why do I need to know about WordPress cron jobs?

As a website owner, do you often try to figure out why certain tasks are not being completed? It may be the case that your WP-cron event hasn’t been working without you knowing it.

A great example of this is the WP Social Ninja plugin. Without any adapted setup, and if new posts aren’t appearing, the cron job isn’t running as it should be. That’s why it is imperative to understand the foundations of WordPress cron jobs. Knowing how they interact with websites can help identify issues early on and prompt appropriate action before more complex technical problems arise.

By taking control, you no longer have to guess what could be causing errors; instead, understanding basic WordPress logic gives you the power to diagnose whenever needed.

So ask yourself: “Why do I need to know about WordPress Cron Jobs?” The answer is simple – because knowledge truly is power!


How does the WordPress cron job work?

The WordPress core installation includes a PHP script called wp-cron.php. The script is triggered whenever someone visits your website or accesses the dashboard, which will execute the tasks.

For most websites, this is fine. But if your website has very few visitors, the scheduled tasks will run infrequently. For websites with heavy traffic, cron job command are triggered a lot and might cause performance issues resulting in a website slowdown.


🚀 Elevate Your WordPress 🚀

Discover the best themes, page builders & plugins at edyrecommends.com! 🔥

Click HERE

How can I control the WP-cron job?

You must log in to your hosting portal and configure the cron jobs. Every good hosting company has a how-to article on this. Click here to see the How To Disable WP-Cron article from 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 event is working?

Unfortunately, this is not possible in standard WordPress core.. You will need to install a plugin. I recommend WP Control (screenshot). After installation, under tools, and cron events, you can see all the cron jobs. The column “next run” gives you an indication of 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. 


WordPress cron job
Plugin WP Crontrol

How to troubleshoot cron job execution from WordPress?

Check if you have a statement in wp-config.php,

define('DISABLE_WP_CRON', true);

If yes, change it to ‘false’ or delete the statement completely. In this case, WP cron job will be enabled on the client side.

If it looks OK (wp-cron.php present, cron job not disabled in wp-config.php), then a plugin will likely conflict with the cron jobs. 

Do you have a cache or security plugin installed? If yes, disable the cache plugin and check again under tools and 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 make sure they are removed from the database. You can then reinstall the plugin and start fresh.


My Synology article series


Real Cron Job Tutorial: How to enable your site on the hosting server

To avoid performance issues, you can disable cron in WordPress and configure it on the server side.

First, go to your hosting dashboard and check in the file manager if the file wp-cron.php is there. 


Namehero cPanel
NameHero – CPanel

wp config
wp-config.php and wp-cron.php

Second open/edit the wp-config.php file in the file manager.

Check for the statement.

define('DISABLE_WP_CRON', true);

If present in the wp-config.php, it means WordPress cron jobs are disabled. For running server cron jobs, the statement should be ‘true’.

Next, search for ‘cron’ in the CPanel or go to the ‘Advanced’ section


Server Cron Jobs
Cron Jobs

See my screenshot of how the mask looks to ‘add a new cron job’

server cron job
Add new cron job

Set the frequency of how often you want to execute the cron job. I set it to one minute. It depends on what plugin you have installed. I recommend one minute if you have a woocommerce shop or for collecting information.

See below an example of my server cron job set in CPanel

WordPress cron example
server cron job

It is a pretty straightforward task to set up a server cron job. Backup plugins like WPvivid can impact your server resources and run unreliable with WordPress cron jobs. If you experience this, I recommend switching to server cron.


FAQ

How do cron jobs help WordPress?

Cron jobs are a useful tool for automating tasks in WordPress. They allow you to schedule tasks such as checking for updates, publishing posts, and running backups at specific times. This helps to ensure that your website is always up-to-date and running smoothly.

Using cron jobs can save you time and energy by automating mundane tasks that would otherwise need to be done manually. Additionally, they can help ensure that your website is secure by regularly running backups and updating plugins and themes.

Why would I need to view my cron jobs?

Viewing your cron jobs is important for a few reasons. It helps you keep track of any tasks that have been scheduled within WordPress and makes sure that they are running as expected. This can help to prevent errors or unexpected delays in tasks like website backups, plugin and theme updates, and more.

What is the difference between WordPress cron and server cron?

The main difference between WordPress cron and server cron is that WordPress cron runs tasks in the background whenever someone visits your website, while server cron runs tasks at specific times according to a schedule.

Is cron still a good choice?

Cron is a powerful tool for scheduling tasks on Unix-like operating systems, and it’s still an excellent choice for many applications. Cron allows users to set up commands executed at specific times or intervals, making it ideal for automating tasks like backups, system maintenance, and more. With cron, you can schedule daily, weekly, monthly, or even yearly jobs. It also supports more complex scheduling patterns, such as running jobs every other day or on specific days of the week.

Cron is easy to use and reliable; however, it does have some drawbacks. For example, cron jobs are limited to one-minute intervals and can’t be scheduled with greater precision than that.

Conclusion

If you are experiencing issues with your WordPress website, it is likely due to an issue with your WordPress cron job. This article showed you how to troubleshoot the most common WordPress cron job issues. If you still can’t resolve your issue, I recommend you seek help from a WordPress professional.

Also, if you are already on a proper WordPress hosting plan and need more reliable cron job scheduling, switching to server cron jobs is recommended. Doing this will provide you with the best performance and reliability.

Did this article help you resolve your problem? If yes, please leave a comment below or write me an email at [email protected]


Check out my blog page

WordPress for Beginners 2023: A Visual Step-by-Step Guide to Mastering WordPress (Webmaster Series)
  • Williams, Dr. Andy (Author)
  • English (Publication Language)
  • 288 Pages – 01/14/2023 (Publication Date) – Independently published (Publisher)
Sale
WordPress For Dummies (For Dummies (Computer/Tech))
  • Sabin-Wilson, Lisa (Author)
  • English (Publication Language)
  • 480 Pages – 01/07/2021 (Publication Date) – For Dummies (Publisher)
Sale
WordPress All-in-One For Dummies (For Dummies (Computer/Tech))
  • Sabin-Wilson, Lisa (Author)
  • English (Publication Language)
  • 848 Pages – 04/09/2019 (Publication Date) – For Dummies (Publisher)
Sale
WordPress: The Missing Manual: The Book That Should Have Been in the Box
  • MacDonald, Matthew (Author)
  • English (Publication Language)
  • 490 Pages – 11/17/2020 (Publication Date) – O’Reilly Media (Publisher)

2 Comments

  1. How can I view the actual code being executed in each cron? I was hacked and I think it is being re-installed via a cron entry

    1. You can install the plugin WP Crontrol mentioned in the article. There you see all the cron executed with the arguments. This should help to find any suspicious cron jobs.

Leave a Reply

Your email address will not be published. Required fields are marked *