WordPress Cron Job

Why not to use WordPress cron and why all the fuzz?

If you are running your own VPS or if you are on a shared hosting, you might want to keep your resources optimal without over-utilizing them. Meaning: you should disable WordPress cron and use real linux cron instead.
Some shared hosting companies, such as Siteground, have claimed to be one of the best in the business. But then again, they provide you with limits on CPU resources that aren’t good enough for any regular user.

Let’s say that you have a website or two, with up-to 100 real visitors on a daily basis. And to have something like that, your website would have to be little bit popular, in which case there would be huge number of robots (good or bad) visiting your websites too, hundreds or even thousands – you never know.
So, each time someone visits (human or robot) your website, WordPress will trigger its in-built ‘wp-cron’ system. This will kick a huge impact on your CPU time.

“You have exceeded the daily CPU Time limit of your account.”

Seriously? For >100 real visitors a day, only! Yeah.
Anyway, the reason why this happens in most cases is the WordPress cron, which, let’s remind ourselves, triggers the ‘wp cron’ script every time a robot or a human lands on any of your pages.
Exceeding the CPU Time limit means that the execution of your script(s) takes too much CPU resources.

When wp-cron runs, there could be other things running as well, therefore we must put and end to that by controlling the “cron” system.

The cPanel cron

If you have cPanel access, then you need to do the following steps:

1. disable the wp-cron within the ‘wp-config.php‘ file.
To do that, you have to edit that file, and add this line:

define('DISABLE_WP_CRON', true);

2. Within the cPanel dashboard, click on the icon named “Cron Jobs” and configure your new cron job.

Cron jobs app within cPanel
  • under common settings you have to choose how often the cron will run
  • everything else will fill in automatically, except the “Command” field
  • “Command” part – here you need to enter this command in order for cron to work on your domain:
    wget -q -O - http://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
  • Make sure to change the “http” to “https” if you use SSL, and the “yourdomain.com” replace with your own domain name.

The Linux way (“this is the way”)

For those people running their own VPS there shouldn’t be any difficulties, and pictures won’t be needed. It doesn’t matter if you run NginX, or LiteSpeed server or even Apache. “This is the way” 🙂

1. disable the wp-cron within the ‘wp-config.php’ file:
define('DISABLE_WP_CRON', true);
2. run command: crontab -e
3. add the following line anywhere within the file:
*/30 * * * * wget https://yourdomain.com/wp-cron.php
The number “30” means that the cron will run every 30 minutes. In the image below I have set it to 15 minutes.

When you finish, your website will be nicely ‘CPU’ optimized, and you won’t have any problems with your shared hosting provider, or your VPS. However, WordPress cron is useful in many occasions, so you should check first if you need it.

Have a nice day.

More from author


Please enter your comment!
Please enter your name here

Related posts

Latest posts

Winamp is the best music player for Windows PC

Winamp, it really whips the llama's ass! 🙂 The best music player of all time.Old school people should know why. My first music player is...

Preload, DNS Prefetch, Preconnect

Find out what does Preload, DNS Prefetch an Preconnect functions are, how they differ from each other and where to use them.

All in One SEO Pack Pro vs Yoast SEO Pro

The ultimate comparison: All in One SEO pack Pro vs Yoast SEO Pro. Find out which one is the best in the year 2020.