I have found many questions and articles about this but i still have some difficulties. I'm using the following command /usr/bin/php home/domain.com/public_html/cron/script.php I receive the following error Status: 404 Not Found X-Powered-By: PHP/5.2.8 Content-type: text/html
我发现了很多关于这方面的问题和文章,但我仍有一些困难。我正在使用以下命令/ usr / bin / php home / domain.com / public_html / cron / script.php我收到以下错误状态:404未找到X-Powered-By:PHP / 5.2.8 Content-type :text / html
No input file specified.
没有指定输入文件。
i'm using Cpanel, the file is hosted on domain.com/cron/script.php Anyideas, thanks :p
我正在使用Cpanel,该文件托管在domain.com/cron/script.php Anyideas,谢谢:p
4 个解决方案
#1
Try:
wget -O - http://domain.com/cron/script.php
and see if you get a better result.
看看你是否得到了更好的结果。
Edit: added "- O - " to not write output to home folder.
编辑:添加“ - O - ”以不将输出写入主文件夹。
#2
Put a leading slash on the script name, i.e.
在脚本名称上加上一个前导斜杠,即
/usr/bin/php /home/domain.com/public_html/cron/script.php
Unless you actually intend to run the script through the web, as in lacqui's answer, and you don't mind random third parties being able to run it any time they like, there's no reason you should put it inside your public_html directory; quite the opposite.
除非你真的打算通过网络运行脚本,就像在lacqui的回答中那样,并且你不介意随机的第三方能够在他们喜欢的任何时候运行它,你没有理由把它放在你的public_html目录中;恰恰相反。
#3
You might need to use the binary known as php-cli instead of just php.
您可能需要使用称为php-cli的二进制文件而不仅仅是php。
#4
I'm realising that it is an old question and that you may have found a solution but none of the answers above helped me and I was getting the same 404 error when I was running a cron script.
我意识到这是一个老问题,你可能已经找到了解决方案,但上面的答案都没有帮助我,当我运行cron脚本时,我得到的是同样的404错误。
The problem was related to the way in which the path to the php script was written. The path must start from public_html like this /usr/bin/php public_html/public/index.php
问题与编写php脚本的路径的方式有关。该路径必须从public_html开始,如/ usr / bin / php public_html / public / index.php
#1
Try:
wget -O - http://domain.com/cron/script.php
and see if you get a better result.
看看你是否得到了更好的结果。
Edit: added "- O - " to not write output to home folder.
编辑:添加“ - O - ”以不将输出写入主文件夹。
#2
Put a leading slash on the script name, i.e.
在脚本名称上加上一个前导斜杠,即
/usr/bin/php /home/domain.com/public_html/cron/script.php
Unless you actually intend to run the script through the web, as in lacqui's answer, and you don't mind random third parties being able to run it any time they like, there's no reason you should put it inside your public_html directory; quite the opposite.
除非你真的打算通过网络运行脚本,就像在lacqui的回答中那样,并且你不介意随机的第三方能够在他们喜欢的任何时候运行它,你没有理由把它放在你的public_html目录中;恰恰相反。
#3
You might need to use the binary known as php-cli instead of just php.
您可能需要使用称为php-cli的二进制文件而不仅仅是php。
#4
I'm realising that it is an old question and that you may have found a solution but none of the answers above helped me and I was getting the same 404 error when I was running a cron script.
我意识到这是一个老问题,你可能已经找到了解决方案,但上面的答案都没有帮助我,当我运行cron脚本时,我得到的是同样的404错误。
The problem was related to the way in which the path to the php script was written. The path must start from public_html like this /usr/bin/php public_html/public/index.php
问题与编写php脚本的路径的方式有关。该路径必须从public_html开始,如/ usr / bin / php public_html / public / index.php