代码之家  ›  专栏  ›  技术社区  ›  Sandeepan Nath

cron正在运行,但功能不工作

  •  6
  • Sandeepan Nath  · 技术社区  · 14 年前

    我有几个PHP文件要由cron运行。我用命令设置crons-

    crontab crontab.txt
    

    在crontab.txt文件中,我编写了如下cron命令:

    #(Updating tutor activities) - every minute
    * * * * * /usr/bin/wget -O - -q -t 1 http://project/cron/tutor_activities.php
    

    但是这些功能都不起作用(数据库查询、发送提醒邮件等)。手动运行URL可以工作。

    然后我把我的邮箱地址放进去 MAILTO 收到了邮件。在邮件中,我收到了整个页面的HTML源代码。邮件中需要什么?为什么我的功能不起作用?

    更新
    如果我把cron命令改为

     #(Updating tutor activities) - every minute
        * * * * * /usr/bin/wget http://project/cron/tutor_activities.php
    

    仍然没有成功,这是我的邮件-

    --15:03:01--  http://project/cron/tutor_activities.php
              => `tutor_activities.php'
    Resolving project... IP Address
    Connecting to test.project|IP Address|:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: http://project./ [following]
    --15:03:01--  http://project./
              => `index.html.1'
    Resolving project.... IP Address
    Connecting to project.|IP Address|:80... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: http://project/home/ [following]
    --15:03:01--  http://project/home/
              => `index.html.1'
    Resolving project... IP Address
    Connecting to wproject|IP Address|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: unspecified [text/html]
    index.html.1 has sprung into existence.
    Retrying.
    

    还有很多 index.html.1 , index.html.2 文件正在我的项目根目录中累积。我不希望创建这些文件。只想执行文件。

    如果我使用这两个命令中的任何一个,结果都相同-

       * * * * * /usr/bin/wget http://project/cron/tutor_activities.php
    
       * * * * * wget http://project/cron/tutor_activities.php
    

    运行 php 命令与 麦尔托 set向我发送这个错误/bin/sh:php:找不到命令。

    * * * * * php /path/to/test.php
    

    所以,我不能用 PHP 命令。

    我写了一个简单的 mailto() 在我的test.php中。当通过cron(同时使用两者)运行时,邮件不会出现 wget PHP 失败),但手动运行URL可以工作。

    我的问题
    再次澄清,我的主要问题是cron文件中的功能没有运行。创建文件是第二个问题。

    任何帮助都将不胜感激

    谢谢,
    桑迪桑

    7 回复  |  直到 14 年前
        1
  •  7
  •   oezi    14 年前

    wget php /...pathtomyscript.../cron/tutor_activities.php

        2
  •  7
  •   Nishant Shrivastava    14 年前

        3
  •  1
  •   dj_segfault    14 年前

        4
  •  1
  •   Petah    14 年前

        5
  •  1
  •   Marc B    14 年前

    * * * * * /path/to/php /path/to/test.php
    

    wget -O - ... http://....     > /dev/null
    

    -O - > /dev/null 2&>1 /dev/null

        6
  •  1
  •   Sandeepan Nath    14 年前

    http://www.test.project.com/cron/tutor_activities.php http://test.project.com/cron/tutor_activities.php www

    http://www.test.project.com/home

        7
  •  0
  •   kanaka    14 年前

    * * * * * bash -c "/path/to/php <(/usr/bin/wget -O - -q -t 1 http://project/cron/tutor_activities.php)"
    

    <()

    which php