php -mkdir()手动工作,但在由cron执行时不起作用
我需要创建一个每日目录(/yyyymmdd)。我正在使用mkdir()函数。当我手动运行它时,它可以正常工作,但是当它由Cron执行时,它无法创建目录。
我认为问题是关于权限的,但我什至尝试将目录修改为777,但仍然无法正常工作。
这是我使用mkdir()的方式:
if (!file_exists($auxfile)) {
if (!@mkdir($auxfile, 0777, true)) {
$error = error_get_last();
echo $error['message'];
}
}
I need to create a daily directory (/YYYYMMDD). I am using mkdir() function. It works fine when i run it manually, but when it is executed by cron, it is not able to create the directory.
I think the problem is about permissions, but I even tried modifying the directory to 777 and still not working.
Here is how I am using mkdir():
if (!file_exists($auxfile)) {
if (!@mkdir($auxfile, 0777, true)) {
$error = error_get_last();
echo $error['message'];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您以DirectAdmin中的典范进行老跑道。您需要确保使用家庭路径。例如
mkdir('/home/domain.com/public_html/results/'.$ auxfile);
If you do it old-skool by example in DirectAdmin. You need to make sure to use the home path. E.g.
mkdir('/home/DOMAIN.COM/public_html/results/'.$auxfile);