I am looking to run a PHP script with a cron job, but it seems I don't have a PHP binary. Looks like I don't have PHP installed as a CGI, so without reinstalling/configuring my PHP, what is the best way to run a php file? I would prefer to not have the file public facing, so some solutions like wget seem a bit hacked. Thank you!

3 Answers 3


You are going to have to pick one. Install the cli/cgi binary or use wget/curl to make a request to your web server.

If you want to protect the script you could adjust the configuration of the web server to block access except from local host, or add something to the script to return an error if the request didn't originate from the local host.

Of course you could also translate the script into something else, but if you need to use libraries common to a web app this is probably not worth the effort.

  • The CLI Binary is what i always use, either that or learn some bash ;)
    – grufftech
    Aug 18, 2010 at 18:14

Looks like I will just protect it, as Zoredache mentioned. For future peeps here is a good link that answered most of my questions about the Apache module vs. CGI binary: http://www.how2dev.com/running-php-scripts-using-cron/

My only concern was that a public facing link would not be immune to denial of service attacks, but only allowing localhost sounds like the answer to mitigate that. Thank you!


You can compile PHP Scripts to Executables... http://wiki.swiftlytilting.com/Phc-win

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy