du248227
2009-03-28 04:39
浏览 81
已采纳

如何在cron中运行php脚本

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

No input file specified.

i'm using Cpanel, the file is hosted on domain.com/cron/script.php Anyideas, thanks :p

图片转代码服务由CSDN问答提供 功能建议

我发现了很多关于此的问题和文章,但我仍有一些困难。 我正在使用以下命令 / usr / bin / php home / domain.com / public_html / cron / script.php 我收到以下错误 状态:404 Not Found X-Powered-By:PHP / 5.2.8 Content-type: text / html

未指定输入文件。

我正在使用Cpanel,该文件托管在domain.com/cron/script.php上 Anyideas,谢谢:p

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • doufang6268 2009-03-28 04:42
    已采纳

    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.

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • dongsi3826 2009-03-28 04:44

    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.

    评论
    解决 无用
    打赏 举报
  • drzb7969753 2009-03-28 05:08

    You might need to use the binary known as php-cli instead of just php.

    评论
    解决 无用
    打赏 举报
  • doutang2017 2012-09-01 18:44

    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.

    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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题