linux下怎么用计划任务执行PHP创建文件夹

WBOY
Release: 2016-06-06 20:46:51
Original
1142 people have browsed it

<code>    #!/kubi/local/php/bin/php -q 
    <?php function  Directorys($dir){    
            return   is_dir ( $dir )  or  (Directorys(dirname( $dir ))  and   mkdir ( $dir , 0777));
        }
$urls = './kubi/local/apache2/htdocs/kubi/Upload/'.date('Y').'/'.date('m').'/'.date('d').'/'.$lujing;
Directorys($urls);
</code></code>
Copy after login
Copy after login

绝对路径 相对路径我都用了都不能创建 如果用浏览器执行这个文件是可以创建的 用linux计划任务就是不可以

回复内容:

<code>    #!/kubi/local/php/bin/php -q 
    <?php function  Directorys($dir){    
            return   is_dir ( $dir )  or  (Directorys(dirname( $dir ))  and   mkdir ( $dir , 0777));
        }
$urls = './kubi/local/apache2/htdocs/kubi/Upload/'.date('Y').'/'.date('m').'/'.date('d').'/'.$lujing;
Directorys($urls);
</code></code>
Copy after login
Copy after login

绝对路径 相对路径我都用了都不能创建 如果用浏览器执行这个文件是可以创建的 用linux计划任务就是不可以

你的代码里, 递归创建 nested directory的过程 确实很有趣.

但为什么不直接mkdir ( $dir , 0777, true)?

http://sg2.php.net/mkdir

recursive
 Allows the creation of nested directories specified in the pathname.

试一下是不是这个引起的问题.

我认为你应该检查一下权限的问题。php执行的权限是否有权限来在该目录创建文件

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
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!