How to run PHP script in cron

I have found many questions and articles about this, but I still have some difficulties. I use the following command / usr / bin / php home / domain.com / public_html / cron / script.php I get the following error Status: 404 Not found X-Powered-By: PHP / 5.2.8 Content-type: text / html

No input file specified.

I am using cpanel, the file is hosted on domain.com/cron/script.php Anyideas, thanks: p

+4
source share
4 answers

Try:

wget -O - http://domain.com/cron/script.php 

and see if you get the best result.

Edit: Added "- O -" to not write output to the home folder.

+5
source

Put the main slash in the script name, i.e.

 /usr/bin/php /home/domain.com/public_html/cron/script.php 

If you are not really going to run the script over the Internet, as in response to lacqui, and you do not mind random third parties who can run it at any time convenient for them, there is no reason why you should put it in your public_html catalog; quite the opposite.

+11
source

You may need to use a binary known as php-cli, not just php.

+1
source

I understand this is an old question, and you might have found a solution, but none of the answers above helped me, and I got the same 404 error when I ran the cron script.

The problem was related to the way the path to the php script was written. The path should start with public_html as follows: /usr/bin/php public_html/public/index.php

+1
source

All Articles