php -mkdir()手动工作,但在由cron执行时不起作用

发布于 2025-01-31 16:06:11 字数 324 浏览 4 评论 0原文

我需要创建一个每日目录(/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七度光 2025-02-07 16:06:11

如果您以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);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文