0

我需要每分钟运行一个 php 文件,所以我尝试从 cpanel 设置一个 cronjob,但它正在发送带有消息“无法打开输入文件:”的邮件

我的 php 文件在 public_html/schoolerp/cron.php

我做了:

/usr/local/bin/php -f /public_html/schoolerp/cron.php

我做错了什么请告诉我我是否设置正确,如果我错了请帮助我纠正它...

4

2 回答 2

3
  • Use absolute paths
  • Make sure that the script is accessible, check access permissions of file/directories on path
  • cron by default will take all the output of your script and send it to your email

You can redirect the output of your command to file or /dev/null to prevent cron from sending email. I would suggest redirect to local file for future references, it's good for debugging and when something goes wrong.

I think something like this should do:

/usr/local/bin/php -f /public_html/schoolerp/cron.php > /logs/mylog.txt 2>&1

Redirect to mylog.txt file and append stderror to stdout so that both stderror and stdout is in log file.

于 2009-06-26T07:37:44.547 回答
1

不确定这是否是一个完整的修复,但您正在使用“/public_html/schoolerp/cron.php”的绝对路径,而这似乎不太可能是正确的。您可能正在寻找“public_html/schoolerp/cron.php”的相对路径(注意前面缺少“/”)。不过,您可能只想使用从文件系统根目录开始的正确绝对路径。

于 2009-06-26T07:23:43.933 回答