Wordpress Cron



  • Run and bulk run selected cron jobs. Quick edit the cron jobs with a simple wordpress like tool directly in the list. Manage your screen display options in the top right corner “Screen Options” section. Get help and documentation about cron jobs.
  • WordPress, Joomla, Drupal, ModX and others CMS Hosting, MySQL - 1st Web Hosting provider in Victoria, Vancouver Island, BC, Canada. Webmail Please consider switching to our new and improved hosting service: Islandhosting.com.
  • If you schedule a post or a backup, for example, WordPress cron will check for them, and then launch them. The thing is that WordPress cron is executed when someone visits your website – every single time someone visits your website, that is. So, if you have a lot of traffic, then having WordPress cron triggering every time someone visits your website will create a lot of calls to the wp.

How to improve the performance of your WordPress website should be on the top of your list. Overall performance is important for the website for a number of reasons. You want the site running fast, and you need to have it properly optimized. One of the best ways to improve performance on a website is to disable cron.

What Are Cron Jobs in WordPress?

WP-Cron is how WordPress handles scheduling out time-based tasks. A number of very important core features in WordPress use WP-Cron. These will include but are not limited to:

2 days ago  I'm hoping to write a cron to automatically change the custom post type for any items that match a particular CPT each night at midnight. For instance: I have a CPT called 'members,' but at midnight or so each day, I am hoping to flip any items with that CPT to just a regular 'posts' post type. CRON jobs are used to schedule tasks at periodic fixed times, dates, or intervals on your WordPress site. Some examples of a WordPress cron job might involve scheduling a post to publish, checking for updates, or a backup plugin running on a predefined schedule. In WordPress, this is handled by WP-Cron, which is used to simulate a system cron.

  • Checking for Updates
  • Publishing Scheduled Posts
  • Backup Plugin Running on a Predefined Schedule

The “Cron” part of the name WP-Cron comes from the cron time-based task scheduling system that is available on UNIX systems.

Basically, WP-Cron works by checking, on every page load, a list of scheduled tasks. This way it can see what needs to run. Any tasks due to run will be called during that page load.

Note: WP-Cron does not run as constantly as the system cron does. It is only triggered on page load.

Why Use WP-Cron?

Even though WP-Cron PHP can have an effect on the overall performance of your website, there are still several good reasons to use it. Honestly, unless your website deals with very high traffic, you probably don’t need to worry about how often the system runs.

That being said, you do have the ability to disable cron in WordPress whenever you want. Before I show you how to do that, let’s look at some good reasons to use WP-Cron.

  • The WordPress core and many plugins need a scheduling system to perform time-based tasks. Cron jobs get this done.
  • Using the WordPress API is a much easier way to set scheduled tasks than going outside of WordPress to the system scheduler.
  • With WP-Cron, all scheduled tasks are put into a queue and will run at the next opportunity. The next opportunity really means at the next page load.

Note: There is no way to be 100% sure when the task will actually run. However, you can be 100% sure that it will indeed run.

Why Does WP-Cron Cause Performance Issues?

WP-Cron is the built-in cron handler for WordPress. Many high traffic and high demand and interaction websites may find they have issues with this. See, WP-Cron is not a real cron job. Instead, it is the system WordPress has created to mimic what a system cron does.

And while sites with high traffic can have issues, sites with very little traffic can suffer performance issues as well. This is because when not many people are loading a page, then a schedule has a higher chance of being missed.

A solution to this is to disable cron and then use the system cron instead. This will help you better run a predefined schedule.

With that being said, let’s take a look at how to easily pull off a WP-Cron disable method. I will also show you how to create a cron job using cPanel after WP-Cron has been disabled.

How to Disable WP-Cron

In order to disable WP-Cron, you need to access the wp-config file for your website. To do this, log into cPanel and click on the “File Manager”icon.

Once inside the file manager, click on the “public_html folder” and then search and open the wp-config file.

Go ahead and open the wp-config file and add this line into it:

You want to add this down at the bottom of the file around line 68. Right before the end of the file. See where I added it in the following screenshot.

Once this is added, go ahead and save the file and you are good to go. At this point, WP-Cron has been disabled.

You can choose to just move on from here, as we have disable cron in order to improve performance. However, it is still a good idea to create cron jobs and make sure certain tasks are being handled.

Wordpress

You can create your own channel and have total control. Let’s take a look at how together.

Note: Make sure you disable the default WP-Cron first, as we did together above.

Create a Cron Job in cPanel

In order to create your own cron job, you will need to log back into your cPanel. If you are still in there because you just accessed the wp-config file, great.

Scroll down to the “Advanced” section of your cPanel and click on the “Cron Jobs” icon.

You will see there is an “Add New Cron Job” page now. Go ahead and add in the settings you want under the Common Settings area. There are several predefined schedules to choose from. These will include options like twice per day, once per week, and many more.

Simply choose the one you want and the box will auto-fill.

Finally, you need to add the following line of code into the command line:

You want to replace the https://domain.com portion with your domain. So don’t forget that.

You can see it done here in the screenshot as well.

Wordpress

Note: This command could vary slightly based on how your hosting is configured.

Now click on the “Add New Cron Job” button and you are good to go.

That’s it! You have successfully added your own cron job using cPanel.

Easy Cron

Lastly, if you are not comfortable with creating your own cron jobs in cPanel, or if your web host does not provide you with that access, then you have another option. You can use a solid third-party solution like Easy Cron.

This solution is a great alternative to what we did above. They will give you all the tools necessary to perform all the cron functions you need. Give them a look if you are not comfortable with what we went over together above.

It is basically allowing you to perform all the same functions, but giving you an easier way than to make the changes yourself.

Final Thoughts

There is a lot to think about if you want to disable cron in WordPress. Yes, your site may run smoother, but you still need it to perform certain functions. For this reason, it is a good idea to create your own cron jobs in cPanel or by using a third-party solution.

I showed you how to not only disable cron, but also how to create your own cron jobs using cPanel. Furthermore, if you are not comfortable with that, then you can check out the suggested Easy Cron solution.

I hope this tutorial has shown you how easy it is to disable cron in WordPress in order to improve performance. You may need to do some research or go slowly through the process if it is your first time, but you will get there.

Not everything in WordPress can be handled with a plugin. While this method is definitely preferred, in some instances you need to have knowledge of your website files, how to access them, and how to configure certain options.

What Is Wp Cron

Have you disabled cron on your WordPress site before? Have you found that there is a link to that and better overall performance?

Author: Jeremy Holcombe

Growing up in Hawaii, Jeremy started his freelance writing career doing resumes, business plans, article writing, and everything in between. He now specializes in online marketing and content writing and is part of the Content Marketing Team at GreenGeeks.

Was this article helpful?

Related Articles

Description

Clean up database by deleting orphaned items such as ‘old revisions’, ‘spam comments’, optimize database and more…

If you have been using WordPress for a while, then you should think absolutely about a database cleanup. Indeed, your database may be full of garbage that makes your site sluggish and bloated such as old revisions, orphaned post meta, spam comments, etc. You should clean-up this unnecessary data to reduce your database size and improve website speed and performance. In addition, you will have quicker database backup since the file of your backup will be smaller.

‘Advanced Database Cleaner’ is a must-have plugin that allows you to clean database, optimize database and more.

Main Features

  • Delete old revisions of posts and pages
  • Delete old auto drafts
  • Delete trash posts
  • Delete pending comments
  • Delete spam comments
  • Delete trash comments
  • Delete pingbacks
  • Delete trackbacks
  • Delete orphan post metadata
  • Delete orphan comment metadata
  • Delete orphan user metadata
  • Delete orphan term metadata
  • Delete orphan relationships
  • Delete expired transients
  • Display and view orphaned information before making a database clean-up so you can be sure about what you are going to clean-up
  • Search & filter all items based on their names or values
  • Keep last x days’ data from being cleaned: clean only data older than the number of days you have specified
  • Schedule database clean up to run automatically
  • Create as many scheduled cleanup tasks as you need and specify what items should be cleaned by the scheduled task
  • Scheduled tasks can be executed based on several frequencies: Once, hourly, twice a day, daily, weekly or monthly
  • Display database tables information such as the number of rows, table size, etc.
  • Optimize database tables (The plugin will notify you if any tables require optimization)
  • Repair corrupted database tables or damaged ones (The plugin will notify you if any tables are corrupted or damaged)
  • Schedule database optimization and/or reparation to run automatically and specify what tables should be optimized and/or repaired
  • Empty database tables rows
  • Clean and delete database tables
  • Display options list
  • Display options information such as option name, option value, option size, option autoload
  • Clean and delete options
  • Set options autoload to no / yes
  • Display active cron tasks list (scheduled tasks) with their information such as arguments, next run, etc.
  • Clean and delete scheduled tasks
  • User-friendly and simple to use

Multisite Support

  • The plugin is compatible with Multisite installations
  • Only the main site can view, clean and optimize the whole network. Other sites in the network cannot perform these tasks. We have opted for this philosophy because we are sure that your DB is precious and only the super administrator can perform such actions
  • You can clean up all sites from one place (the main site). You can also specify specific sites you want to cleanup

By using the ADC plugin, you will

  • Get and overview: The plugin will help you get an overview of what is happening in your database. It will report all unused/orphaned items that should be cleaned, it will give you the number of tables/options/tasks you have, etc. This way, you can control your database if anything goes wrong

  • Save time: You can specify what items should be cleaned/optimized/repaired, what is the number of days’ data to keep and the cleanup/optimization/reparation frequency. The plugin will then automate the process to run automatically based on your settings

  • Save space: By deleting unused/orphaned items, you will save space in your database and make quicker backups since the file of your backup will be smaller

Pro Features (Official website)

Do you know that even after deleting a plugin/theme from your WordPress website, some of its leftovers may remain in your database? Such as orphan options, orphan tables, and orphan cron tasks. As you may know, not all plugins/themes care about the housekeeping of your WordPress database. As long as you are removing plugins/themes, leftovers will be accumulated in your database and will influence your website performance. The Pro version of Advanced Database Cleaner will help you remove all those leftovers and perform a deep database clean up. In the pro version you can:

  • Classify options according to their “creator”. They can be either: plugins options, themes options or WP core options
  • Detect and delete orphan options. Your ‘wp_options’ table may be full of orphaned options and therefore can impact the performance of loading data from it, which may lead to a slow website. Clean up orphaned options is then important
  • Classify tables according to their “creator”. They can be either: plugins tables, themes tables or WP core tables
  • Detect and delete orphan tables. As for options, you may also have some orphaned tables that were created by plugins/themes you are not using anymore. Clean up orphaned tables will decrease the size of your database
  • Classify all cron tasks (cron jobs) according to their “creator”. They can be either: plugins cron tasks, themes cron tasks or WP core tasks
  • Detect and delete orphan cron jobs. After you uninstall a plugin/theme, some of its cron tasks may still be active making WordPress calling unknown functions. using the pro version, you can detect and clean orphaned tasks
  • Search & filter options, filter tables and filter cron tasks based on several criteria such as the “name”, “creator”, “value”, etc.
  • Get premium support: we will provide quick support as well as any technical answers to help you clean up your database efficiently
What

Translations

You are welcome to contribute to the plugin translation via the WordPress translation website.

Thanks To

  • Fabio Fava for translating the plugin to pt_BR
  • Julio Potier for the security remarks

Installation

This section describes how to install the plugin. In general, there are 3 ways to install this plugin like any other WordPress plugin.

1. Via WordPress dashboard

  • Click on ‘Add New’ in the plugins dashboard
  • Search for ‘advanced-database-cleaner’
  • Click ‘Install Now’ button
  • Activate the plugin from the same page or from the Plugins dashboard

2. Via uploading the plugin to WordPress dashboard

  • Download the plugin to your computer from (https://wordpress.org/plugins/advanced-database-cleaner/)
  • Click on ‘Add New’ in the plugins dashboard
  • Click on ‘Upload Plugin’ button
  • Select the zip file of the plugin that you have downloaded to your computer before
  • Click ‘Install Now’
  • Activate the plugin from the Plugins dashboard

3. Via FTP

  • Download the plugin to your computer from (https://wordpress.org/plugins/advanced-database-cleaner/)
  • Unzip the zip file, which will extract the ‘advanced-database-cleaner-3.0.0’ directory
  • Upload the ‘advanced-database-cleaner’ directory (included inside the extracted folder) to the /wp-content/plugins/ directory in your web space
  • Activate the plugin from the Plugins dashboard

For Multisite installation

  • Log in to your primary site and go to “My Sites” » “Network Admin” » “Plugins”
  • Install the plugin following one of the above ways
  • Network activate the plugin (Note that only the main site can have access to the plugin)

Where the plugin menu will be displayed?

  • The plugin page can be accessed via “Dashboard” » “Tools” » “WP DB Cleaner” or via the left menu “WP DB Cleaner” (You can change this via the plugin settings)

FAQ

What does mean “clean my database”?

As you use WordPress, your database accumulates a lot of extra data such as revisions, spam comments, trashed comments, etc. Removing this unnecessary data will reduce your database size, speeds up your backup process and speeds up your site also.

Is it safe to clean my database?

Yes, it is. We do not run any code that can break down your site or delete your posts, pages, comments, etc. However, make sure to always back up your database before any cleanup. This is not optional; it is required! It is always better to be safe than sorry!

What does mean “Optimize my database”?

Optimizing your database will reclaim unused space in your tables, which will reduce storage space and improve efficiency when accessing tables. Optimizing the database can sometimes significantly improve performance, particularly on sites that receive a lot of traffic or have a large amount of content. Optimizing your database is absolutely safe.

Is it safe to clean the cron (scheduled tasks)?

A scheduled task enables plugins to execute some actions at specified times, without having to manually execute code at that time. WordPress itself uses some scheduled tasks to perform some regular actions. However, some scheduled tasks may not be removed even if the responsible plugins are deleted from your WordPress installation. As you know, not all plugins care about the housekeeping of your WordPress. Hence, deleting these unnecessary tasks may help in cleaning your site. It should be noted that cleaning scheduled tasks is safe as long as you know what tasks to clean. If you are not sure, it is better to not clean any task.

What does mean “Revision”? What sql code is used to clean it?

WordPress stores a record (called “revision”) of each saved draft or published update. This system allows you to see what changes were made in each post and page over time. However, this can lead to a lot of unnecessary overhead in your WordPress database, which consumes a lot of space. The sql query used by the plugin to clean all revisions is:
DELETE FROM posts WHERE post_type = ‘revision’

What does mean “Auto-draft”? What sql code is used to clean it?

WordPress automatically saves your post/page while you are editing it. This is called an auto-draft. If you don’t hit the publish/update button, then the post/page will be saved as auto-draft and any modification to your post/page will not be visible in your public site. Over time, you could have multiple auto-drafts that you will never publish and hence you can clean them. The sql query used by the plugin to clean all auto-drafts is:
DELETE FROM posts WHERE post_status = ‘auto-draft’

What does mean “Pending comment”? What sql code is used to clean it?

Pending comments are comments published by users and which are waiting for your approval before appearing in your site. In some cases, you will have to clean all these comments. The sql query used by the plugin to clean all pending comments is:
DELETE FROM comments WHERE comment_approved = ‘0’

What does mean “Spam comment”? What sql code is used to clean it?

It is a comment that you (or a plugin) have marked as spam. The sql query used by the plugin to clean all spam comments is:
DELETE FROM comments WHERE comment_approved = ‘spam’

What does mean “Trash comment”? What sql code is used to clean it?

A trash comment is a comment that you have deleted from your WordPress and have been moved to the trash. A trash comment is not visible in your site and should be deleted forever. The sql query used by the plugin to clean all trash comments is:
DELETE FROM comments WHERE comment_approved = ‘trash’

What does mean “trackback”? What sql code is used to clean it?

Trackbacks allows you to notify other websites owners that you have linked to their article on your website. These trackbacks can be used to send huge amounts of spam. Spammers use them to get their links posted on as many sites as possible. That is why they should be deactivated/cleaned if you do not use them. The sql query used by the plugin to clean trackbacks is:
DELETE FROM comments WHERE comment_type = ‘trackback’

What does mean “pingback”? What sql code is used to clean it?

Pingbacks allow you to notify other websites owners that you have linked to their article on your website. Pingbacks were designed to solve some of the problems that people saw with trackbacks. Although there are some minor technical differences, a trackback is basically the same things as a pingback. These pingbacks can be used to send huge amounts of spam. Spammers use them to get their links posted on as many sites as possible. That is why they should be deactivated/cleaned if you do not use them. The sql query used by the plugin to clean pingbacks is:
DELETE FROM comments WHERE comment_type = ‘pingback’

What does mean “Orphan post meta”? What sql code is used to clean it?

The post meta data is the information you provide to viewers about each post. This information usually includes the author of the post, when it was written (or posted), and how the author categorized that particular post. In some cases, some post meta data information becomes orphan and does not belong to any post. They are then called “orphan postmeta” and should be cleaned since they are not useful. The sql query used by the plugin to clean all orphan postmeta is:
DELETE pm FROM postmeta pm LEFT JOIN posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL

Cron

What does mean “Orphan comment meta”? What sql code is used to clean it?

The same as “Orphan post meta” with the exception that “orphan comment meta” concern comments and not posts. The sql query used by the plugin to clean all orphan comment meta is:
DELETE FROM commentmeta WHERE comment_id NOT IN (SELECT comment_id FROM comments)

What does mean “Orphan user meta”? What sql code is used to clean it?

The user meta data is the information you provide to viewers about each user. This information usually includes additional data that is not stored in the users table of WordPress. In some cases, some user meta data information becomes orphaned and does not belong to any user. They are then called “orphaned usermeta” and should be cleaned since they are not useful. The sql query used by the plugin to clean all orphan comment meta is:
DELETE FROM usermeta WHERE user_id NOT IN (SELECT ID FROM users)

Wordpress Cron Job

What does mean “Orphan term meta”? What sql code is used to clean it?

The term meta data is the information that is provided for each taxonomy term. This information usually includes additional data that is not stored in the terms table of WordPress. In some cases, some term meta data information becomes orphaned and does not belong to any taxonomy term. They are then called “orphaned termmeta” and should be cleaned since they are not useful. The sql query used by the plugin to clean all orphan comment meta is:
DELETE FROM termmeta WHERE term_id NOT IN (SELECT term_id FROM terms)

What does mean “Orphan relationships”? What sql code is used to clean it?

Sometimes the wp_term_relationships table becomes bloated with many orphaned relationships. This happens particularly often if you’re using your site not as a blog but as some other type of content site where posts are deleted periodically. Over time, you could get thousands of term relationships for posts that no longer exist which consumes a lot of database space. The sql query used by the plugin to clean all orphan relationships is:
DELETE FROM term_relationships WHERE term_taxonomy_id=1 AND object_id NOT IN (SELECT id FROM posts)

What does mean “expired transient”?

Transients are a way of storing cached data in the WordPress DB temporarily by giving it a name and a time frame after which it will expire and be deleted. This helps improve WordPress performance and speed up your website while reducing the overall server load. Expired transients are transients that are expired and still exist in the database. These ones can be safely cleaned. Transients housekeeping is now part of WordPress core, as of version 4.9, so no need to clean up them manually unless you have specific needs.

Wordpress Cron Job

Is this plugin compatible with multisite?

Wordpress Cron Url

Yes, it is compatible with multisite. It should be noted that only the main site in the network can clean the database and orphan items of all the network. We prevent other sites to clean your DB since we believe that only the super administrator has the right to perform such operation. Your database is precious!

Is this plugin compatible with SharDB, HyperDB or Multi-DB?

Actually the plugin is not supposed to be compatible with SharDB, HyperDB or Multi-DB. We will try to make it compatible in the coming releases.

Wordpress Cron Job Plugin

Does this plugin cleans itself after the uninstall?

We do clean-up of your WordPress site, it will be a shame if the plugin does not clean itself after an uninstall! Of course yes, the plugin cleans itself and removes any data used to store its settings once uninstalled.

Reviews