A geek at home. A web and mobile Apps Developer at Bella Design in Cheshire. A man united fan all day long.

Running wordpress cron jobs on a linux server

February 19th, 2015

I was having an issue with a site that required a database intensive update 4 times a day, we are talking 1000s of  mysql rows updated/deleted/inserted each time. It seemed to be getting by nicely on a test server using wordpress simple cron scheduler. Going live however was a different story, epic failures and error 500s on the clients live website.

Instead of running the script as a hook/function on wordpress I ran it instead using the servers direct crontab, problem solved.The simplest way to get your wordpress functions into an external PHP script is by calling the wp-blog-header.php script as follows

Remember on your linux server use type -a php to find your php interpreter location

You should get something along the lines of

Then at the top of your actual PHP script you’re going to run make sure you add the following line


You may encounter an issue with running your script on the server if your file is not formated correctly and the server complains about not being able to find your PHP interpreter

Simply open your script using VIM and do the following

Your file should now run as any normal PHP file would on a wordpress setup