首页 文章

文件时间的Cron作业错误

提问于
浏览
0

我有一个PHP脚本直接从一个网页运行,检查站点 Map 的所有html文件的最后修改时间,但是如果错误输出我作为一个cron作业运行 .

下面是脚本,cron作业和错误 .

$path = "/home/mydir/"; 

// Open the folder 
$dir_handle = @opendir($path) or die("Unable to open $path"); 

// Loop through the files 
while ($file = readdir($dir_handle)) { 
    if($file == "." || $file == ".." || $file == "index.php" ) 

        continue; 
        if(strpos($file, ".html") !== false) {
        $a=filemtime($file);
        }
    }
}

php /home/mydir/pdate.php / dev / null && echo“站点 Map 已完成”$(日期)>> / var / log / cron.log

错误PHP警告:filemtime():stat失败

关于我应该为这一个改变的想法吗?

1 回答

  • 1

    你在另一个目录中 . 或者:

    chdir($path);
    

    要么:

    filemtime($path.DIRECTORY_SEPARATOR.$file);
    

相关问题