从 cron 运行时 filesize 函数失败
当我从 cron 运行脚本时出现以下错误
警告:filesize() [function.filesize]:/home2/sharingi/public_html 中的 /home2/sharingi/public_html/scrape/zip/dailydose/April_14_2011.zip 统计失败/scrape/zip/zip.php
但是,如果我从浏览器运行该脚本,它就可以正常工作。某种权限问题?
I get the below error when I run my scrip from cron
Warning: filesize() [function.filesize]: stat failed for /home2/sharingi/public_html/scrape/zip/dailydose/April_14_2011.zip in /home2/sharingi/public_html/scrape/zip/zip.php
However if I run the script from my browser it works fine. Some kind of a permissions problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能是与您的 cron 进程运行的用户有关的问题。确保运行的任何 cron 都具有权限,因为它可能与您的 ssh 帐户或 Web 服务器帐户不是同一用户。您可以通过配置 cron 来运行命令
whoami
并通过电子邮件将输出发送给您,从而确定 cron 以哪个用户身份运行。如果您不知道如何实现这一点,您可以尝试将 cron 配置为
wget
您知道有效的公共 URL。不要忘记关闭文件保存,并将其设置为安静模式,否则每次运行都会产生大量垃圾。It's probably an issue related to the user that your cron process runs under. Make sure that whatever cron runs as has permissions, since it's probably not the same user as your ssh account or the webserver account. You can probably figure out which user cron runs as by configuring cron to run the command
whoami
and email you the output.If you can't figure out how to make that work, you might try configuring cron to
wget
the public url that you know works. Don't forget to turn off the file saving, and set it to quiet mode, otherwise you'll get a lot of garbage from each run.如果您处于共享托管环境中,您的 cron 作业可能以您自己的用户身份运行,因此除非您自己没有相关文件的读取权限,否则我想这可能不是问题。
作为一种可能的解决方法,如果您无法轻松了解其底部,这里有一个函数,它应该允许您在不使用 php 内置函数的情况下获取所需的信息。
if you're in a shared hosting environment, your
cron
job is probably running as your own user, so unless you yourself don't have read permissions for the file in question, I imagine that's probably not the issue.As a probable work-around, in case you can't get to the bottom of it easily, here's a function which should allow you to get the info you need without using the php-builtin.