How to replace WordPress cron job with a cPanel managed cron job.

The WordPress cron system handles scheduled tasks that your website and plug-ins require to function. By design the creators of WordPress handle the cron system internally processing these scheduled tasks with every page load. Due to this the WordPress cron feature is open to outside DDoS attack and performance issues due to how frequently it runs. In most cases it is suggested you modify the WordPress script and use the cPanel cron system instead.

Before we add the cPanel cron job you will need to edit your WordPress 'wp-config.php' file and disable the internal cron system. This article uses the cPanel File Manager to edit and make the required change to the 'wp-config.php' file. 

First you will need to access your accounts cPanel interface and locate the 'File Manager' section. You can use the search box at the top of the cPanel interface to find the File Manager. 

When you are inside the 'File Manager' you will need to locate your 'wp-config.php' file, for most clients this is located within the public_html directory. If this is an add-on domain you will need to navigate to your website document directory where the WordPress files are located. You would click on the 'wp-config.php' file once and then use the 'Edit' button at the top to open the file. 

 

When the file is open for editing you will need to add the following code in the location outlined in the image below. Remember to click 'Save Changes' once the code is added to the file. 

define('DISABLE_WP_CRON', true);

After saving the changes to the 'wp-config.php' file it is now time to add the cPanel cron job. Go to the cPanel interface home page and locate the 'Cron Jobs' section. 

In the 'Add New Cron Job' section you would first select 'Twice Per Hour (0,30 * * * *)' under the 'Common Settings' drop-down.  You can set a higher frequency although we do not recommend faster than once every 5 minutes.

You then add the following text in the box under the 'Command:' section. Please note if your site is not in public_html you will enter the folder name where the site is located.  You can find the path for every domain in your cPanel in the 'Domains' section.

php -q ~/public_html/wp-cron.php > /dev/null

 

After clicking 'Add New Cron Job' the process is complete. 

  • cron jobs, wordpress
  • 0 משתמשים שמצאו מאמר זה מועיל
?האם התשובה שקיבלתם הייתה מועילה

מאמרים קשורים

BackupBuddy not working, how can I fix this?

BackupBuddy schedules things to run in the background in a way that isn't inherently...

Cannot upgrade WordPress or a WordPress Plugin

Should you receive an error message about not being able to write or open a file in "/tmp" when...

Critical Error page when visiting site

Manually disabling Wordpress plugins: Occasionally plugins can have issues that will cause a site...

Disabling Maintenance Mode in WordPress

If you are using WordPress and you need to manually disable maintenance mode, you can do so by...

How do I import my WordPress installation into Softaculous?

The WordPress Manager by Softaculous is a fantastic tool for managing your installations...