Cron execution for PHP - mkdir() fails but manual execution succeeds
P粉904405941
P粉904405941 2024-03-30 20:34:15
0
1
421

I need to create a daily directory (/YYYYMMDD). I'm using mkdir() function. When I run it manually it works fine, but when it is executed by cron it fails to create the directory.

I thought the problem was with the permissions, but I even tried modifying the directory to 777 and it still didn't work.

This is how I use mkdir():

if (!file_exists($auxfile)) {
    if (!@mkdir($auxfile, 0777, true)) {
        $error = error_get_last();
        echo $error['message'];
    }
}

P粉904405941
P粉904405941

reply all(1)
P粉381463780

If you are doing it old-style via the examples in DirectAdmin. You need to make sure you use the main path. For example. mkdir('/home/DOMAIN.COM/public_html/results/'.$auxfile);

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!