如何在 cron 作业中设置文件
我需要每分钟运行一个 php 文件,所以我尝试从 cpanel 设置一个 cronjob 但它发送邮件时显示消息“无法打开输入文件:”
我的 php 文件位于 public_html/schoolerp/cron.php
我做了:
/usr/local/bin/php -f /public_html/schoolerp/cron.php
Am我做错了请告诉我是否设置正确,如果我错了请帮助我纠正......
I need to run a php file every minute so I tried to set a cronjob from the cpanel
but it's sending mail with the message "could not open the input file:"
My php file is inside public_html/schoolerp/cron.php
I did:
/usr/local/bin/php -f /public_html/schoolerp/cron.php
Am I doing something wrong please tell me if I am setting it right, and if I am wrong please help me correct it ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可访问,检查路径上文件/目录的访问权限
脚本的输出并将其发送到
您的电子邮件
您可以将命令的输出重定向到文件或 /dev/null 以防止 cron 发送电子邮件。 我建议重定向到本地文件以供将来参考,这有利于调试和出现问题时。
我认为应该这样做:
重定向到 mylog.txt 文件并将 stderror 附加到 stdout,以便 stderror 和 stdout 都在日志文件中。
accessible, check access permissions of file/directories on path
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:
Redirect to mylog.txt file and append stderror to stdout so that both stderror and stdout is in log file.
不确定这是否是一个完整的修复,但您正在使用“/public_html/schoolerp/cron.php”的绝对路径,而这似乎不太可能是正确的。 您可能正在寻找“public_html/schoolerp/cron.php”的相对路径(注意前面缺少“/”)。 不过,您可能只想使用从文件系统根目录开始的正确绝对路径。
Not sure if this is a complete fix, but you are using absolute pathing for '/public_html/schoolerp/cron.php', when that doesn't seem very likely to be correct. You might be looking for a relative path of 'public_html/schoolerp/cron.php' (note the lack of preceding '/'). You may just want to use the proper absolute path starting from the root of the filesystem though.