Heart Internet wp_cron.php

Wordpress uses wp_cron.php to run a host of time sensitive functions and tasks which require running at a specific time of day. If your having problems with the wp_cron.php running as it should and hosted on Heart Internet or even on other hosts with similar setups you may find this extremely useful.

There are a few workarounds on the internet which will get your wp_cron.php file going again but I think my method is the simplest and also lesser mentioned on the web.

Problem

Your wp_cron.php isn’t working and you have no idea why and you hosted on Heart Internet or having the same problem on another host.  Heart Internet employs a security technique to stop it from calling its own files via HTTP and for WordPress this is a problem as that’s exactly how it works.

The fix

Heart Internet comes with 3 possible cron slots in its schedule control panel.  You only need one to run at a frequent time.  Heart Internet also limits the frequency so the most frequent option is once an hour which should be fine.

Enter the following in the ‘Run this command’ option, replacing ‘your domain’ with your actual domain.

/usr/bin/php5 /home/sites/your domain/public_html/wp-cron.php

You can press the ‘Test Command’ button which should show you something similar to this

The page at https://hosting.heartinternet.co.uk says:
 
Your script returned the following:
X-Powered-By: PHP/5.2.17
Content-type: text/html

How it works

I’ll break this into parts two parts.

/usr/bin/php5

This is the path to the PHP5 interpreter; it needs this to use PHP whilst executing your wp_cron.php file.

/home/sites/your domain/public_html/wp-cron.php

This is the path to the file you want executing by PHP

Conclusion

By using the Heart Internet ‘Scheduled Tasks’ and the correct command you can have a working wp_cron.php file and functions running once an hour without editing any config files or adding unnecessary plugins.

This is surly the most appropriate method?

No Comments