Because WordPress has to work on all sort of different platforms, OS’s and configurations, it can’t rely that there will be a cronjob service on the server that can handle scheduled tasks. This is why WordPress developers have created a workaround – the wp-cron.php file in your main WordPress folder is executed every time someone loads a page. It then checks if there’s a scheduled task to be done and executes it if necessary.
However, in some cases, this file may become a target of a DOS attack, or caching plugins can interfere with its execution which can cause either a lot of server load or the scheduled tasks may not execute properly and timely. This is why you can substitute this constant file execution with a real cron job.
First, you need to disable the script to be executed every time someone loads one of your pages. To do this, open the wp-config.php file in your main WordPress folder and add the following line before the “/* That’s all, stop editing! Happy blogging. */” line:
Once you do that, you need to set up a real cron job and execute the wp-cron.php file with it. You don’t want to trigger it too often – 30 minutes should be fine for most of the websites. To do this, go to your hosting control panel and then Cron jobs under the TOOLS section.
Then, add the following command to be executed every 30 minutes:
cd /home/yourdomain.com/public_html; wp cron event run --due-now >/dev/null 2>&1
Replace /home/yourdomain.com/public_html with the actual path to your WordPress application’s core files.
The Cron jobs tool has some of the most common schedules preset, so you can just select Twice Per Hour from the interval drop-down menu.