James John – Software Engineer

Disable WordPress Cron and Use Real Cron Job

Normally, there is no way PHP can run without a page being loaded or without it being executed from CLI. So your WordPress cron how does it go about? Firstly what’s WordPress cron?

What is Cron?

Cron Jobs are software utility that can trigger a defined function based on time given to it, when you receive update notifications in your WordPress Admin it’s done by cron job.

How does WordPress execute this?

Actually, this is not done by the system cron; Once a user hits your page, before page loads and everything is set WordPress uses that time to run it’s cron but some wouldn’t know. This can affect your site loading time because WordPress is busy dealing with daily, hourly, weekly checks once a page loads but what if we stop this and hand over the job to the main system cron? 😉 Pretty cool ye?

For cPanel Users

  1. Login to your cPanel and move to the Cron Jobs tab then open it. Add new cron and set timing at least every 5 minutes then add this to command
    /usr/bin/curl http://yourwpsite.com/wp-cron.php?doing_wp_cron > /dev/null

    and save 🙂
    cronYou’ve successfully created a cron job to do WordPress cron jobs for you 🙂 Check your access logs to confirm if it’s really checking.

For VPS Users

If you are using your own server or a VPS which is running Linux, you can still set this up without cPanel. Just install cURL into your system and run this:

$ sudo crontab -e -u www-data

To the end of the last line, add this

*/5 * * * *  /usr/bin/curl http://mywpsite.com/wp-cron.php?doing_wp_cron > /dev/null

then save and exit with CTRL+X. You are done setting cron to check the website every 5mins to update cron.

James John

Software Engineer