Thursday, 5 November 2015

Use a Real Cron with WordPress

I used to be part of a Network Marketing program that gave me a free blog. I like to post date posts so that i can work the day, setting them up then do what i want to do the rest of the week.

I was starting to notice though that my scheduled posts weren't getting posted. It turns out the "WP Cron" is a virtual cron, NOT a real Cron. So I want to show you how to set this up when you first install wordpress so that you get the best Cron Performance from your site.

The WP-Cron ONLY works when the page is loaded, so you do all your updates and never look at the post, the ONLY Time it's updated is when someone visits that page.

The reason for changing to a Real Cron is because the WP-Cron can kill your site, it can have many conflicts with plugins, dns, wp bugs, caching and large server load to name a few, so doing it this way you know its set and forget.

So lets get into it, it really is easy once you know how. You need to download the file wp-config.php from your domain name. It is in the folder that you have put your blog on to. if your wordpress is in here then it will have wp-config.php if your wordpress is setup like this then it will have wp-config.php in there.

We download it by using our FTP Program. I use FileZilla which is a free ftp program. You can get Filezilla from

You want the client version because your only going to put in your own urls. The ftp details to logon to your domain are your CPanel details usually.

You will have got them from your host when you bought your hosting. If you cannot find them then contact your support on your hosting account.

Once you have ftp into your domain, go to your Public_html folder and navigate to where you installed WordPress.

Download wp-config.php to your local computer. Once it is on your computer you want to right click and open it with your notepad. I use this one to open my files

It is free. Really good and easy to use. Back to the file, after <?php you want to add this line to it

define('DISABLE_WP_CRON', true);

Then you want to click on save. We are going to upload this file back on to our domain, however before doing so, go to where you downloaded it from and rename the file already there. wp-config.php to wp-config.old

This way if anything goes wrong you still have the original file on your server, you can delete the one you upload and rename the one you renamed old, you would then get your settings back to their original set.

Does that make sense.

So NOW on your site you actually have NO Cron running at all because you have just told wordpress through its config file not to run any crons. We now need to go to your CPanel and goto your CRON Section and set one up manually.

The command below tells the Linux server to run wp-cron via wget, which will trigger the wp-cron.php script to do it's job on your schedule instead of on each page view.

So if your blog is installed on the top domain you use this one

wget -q -O - >/dev/null 2>&1

If your blog is in a folder then you use this one

wget -q -O - >/dev/null 2>&1

Remember to change to your OWN Domain. Don't use that exactly because it will not work for you.

When you add the line you need to give it a time to run, I know you might be tempted to set it to run every minute however that is excessive and you will get into trouble from your hosting account if you are on shared etc. So a good number to set it is 15 Minutes. I have mine all set to that and I have never had any problems.

This might be a bit scary for you, however try it and if you do get anything wrong, you still have the original file there, you can then replace and remove any edits you have done quickly and easily.

Honestly this isn't difficult it is good practice and one that you can really do easily enough.

No comments:

Post a Comment