gpt4 book ai didi

php - 文件时间的 Cron 作业错误

转载 作者:行者123 更新时间:2023-12-04 19:21:53 26 4
gpt4 key购买 nike

我有一个 php 脚本,它直接从一个网页运行良好,它检查站点地图的所有 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 "站点地图完成"$(date) >>/var/log/cron.log

错误
PHP 警告:filemtime(): stat failed

请问我应该为这个改变什么?

最佳答案

您在另一个目录中。
任何一个:

chdir($path);

或者:
filemtime($path.DIRECTORY_SEPARATOR.$file);

关于php - 文件时间的 Cron 作业错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15255654/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com