我有几个 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
使用 set运行php
命令MAILTO
向我发送此错误 /bin/sh: php: command not found。
* * * * * php /path/to/test.php
所以,我无法使用php
命令。
我mailto()
在 test.php 中写了一个简单的内容。通过 cron 运行时邮件不会发送(同时使用wget
并php
失败),但手动运行 URL 可以正常工作。
我的问题
再次说明,我的主要问题是 cron 文件中的功能没有运行。创建文件是次要问题。
任何帮助,将不胜感激
谢谢,
桑迪潘