Disable WordPress cron job
To gain some more speed out of your Classipress installation you should disable WordPress Cron Job.
Why is cron job causing high CPU and SQL usage on my Classipress installation?
Well, it’s like this. After you install your Classipress site or even just WordPress site, you will probable install some additional plugins (in my case around 30). Some of these plugins will have their own cron jobs that they need to run regularly. These jobs are inputted into a WordPress options table.
If your website has a lot of ads, running cron jobs constantly will slow down your website, or you will get a warning from your database host that your website is consuming too much CPU time.
To solve this you need to do a few steps after which you will be able to control website’s cron jobs.
You will do this in three steps:
Step 1: Disable WordPress’s cron control
Step 2: Download a plugin to control your cron jobs
Step 3: Run a script to start cron jobs
Step 1
Disable WordPress cron jobs
If you have doubts about this, you can skip this step and do it after you go trough all steps.
Open wp-config.php file and input somewhere before end of file.
You can input after define(‘WPLANG’,”);
/** Disable CRON */ define('DISABLE_WP_CRON', true); |
Step 2
Now that you have disabled cron job, no ads will expire, no emails will be sent to users to renew their ads and no checks for updates will be done. But have no fear, WP-Cron Control is here. With this plugin you will be able to run cron jobs when you want them and only you will be able to run them, since there is a secret pass-phrase that is needed to run this script. But you can read all about it on plugin’s official site.
Step 3
This is the last step that is needed for this to work.
Now, that your cron job is down and you have you have installed WP-Cron Control plugin we need to call this script somehow. Go to Settings of WP-Cron control and there you will see how you can call your script for the crons to be executed.
It is up to you how you will call it. I prefer an online service to do this for two reasons:
– I can be sure it’s working 100%.
– I get an email if something goes wrong even if my site is down and I don’t know about it.
There are a lot of free online cron job services, my favorite is www.easycron.com.
When you decide which one to use, just copy the wget link from WP-Cron Control into your Online Cron Service and set the correct times when you want your cron jobs to be running.
Be avare! Don’t run them too often, or there will be no difference from WordPress’s cron control.
On my website I run cron jobs only twice a day, which is enough for the ads to expire and I don’t care about other updates being run only twice a day.
Additional note
If you want more control over your cron jobs, take a look at this plugin: WP Crontrol. You will be able to control frequency of every cron job.
If you find any issues with this tutorial, please be so kind and write a comment. I’ll try to help as much as I can.
An online cronjob service overview can be found at http://www.cronjobservices.com/
In relation to the first step, where exactly is the wp-options.php file. I can’t seem to find it. Did you mean the wp-config.php file. I want to stop the cron system from working.
Corrected it to wp-config.php. Thank you for this.
Thank you for this tip. I just installed WP Cron Control.. I also notice that CP dashboard under classipress/system info there is a section of a list of Cron Jobs that are running such as:
wp_version_check
wp_update_plugins
wp_update_themes
wp_scheduled_delete
and others……….
1) Is this list the complete list of ALL cron jobs on my WordPress / classipress site? In other words, does this list Includ all the plugin, theme cron jobs, etc…on my wp site?
2) When I activate WP Cron Control, It will override all the cron jobs including all plugin, and theme cron jobs?
3) Will I have to set up each and every one of these cron jobs in Cpannel or Easycron?
Hi,
1) Yes the list under Classipress>System info is a complete list of all cron jobs on your WP installation.
2) Plugin WP Cron control will give you an option to start your ALL cron jobs manually with a secret key, so no one else can do that.
3) You don’t have to setup multiple jobs, only one is enough.
How this is done:
When you install WP Cron Control you will be able to call cron job from outside script (EasyCron). You will do this with a secret key.
Go to WP Cron Control settings page and there you will see a string that you have to call from EasyCron. Copy that string and go to EasyCron and there create one new job and give it this string. Select how often you want to run that cron.
The EasyCron server will then call this string and ALL jour cron jobs in WP installation will be run at once.
If you don’t disable cron job in WP, then WP will still run cron jobs based on timings and your EasyCron setup will just do some additional calls that will slow down your system.
So with disabling WP cron job you take control when cron jobs will be run.
Hope I helped.
Blaz
Blaz, Thank you for your reply, I just set it up. I will monitor it to see that it works properly.
Also, for those using EasyCron this page may help also:
https://www.easycron.com/cron-job-tutorials/how-to-set-up-cron-job-for-wp-cron-control.