View Single Post
Old 01-13-2025, 03:44 PM  
Publisher Bucks
Confirmed User
 
Industry Role:
Join Date: Oct 2018
Location: New Orleans, Louisiana. / Newcastle, England.
Posts: 1,129
Any idea why this cron job isnt doing its job?

It *was* working but stopped about a week ago, nothing has changed on the hosting account to my knowledge

Quote:
<?php

$directories = [
'/path/to/directory1',
'/path/to/directory2',
'/path/to/directory3'
'etc...'
'etc...'
];

$threshold = 30 * 24 * 60 * 60; // 30 days

foreach ($directories as $directory) {
if (is_dir($directory)) {
$dir = opendir($directory);

while (($file = readdir($dir)) !== false) {
if (pathinfo($file, PATHINFO_EXTENSION) === 'jpg') {
$filePath = $directory . DIRECTORY_SEPARATOR . $file;

if (file_exists($filePath) && time() - filemtime($filePath) > $threshold) {
unlink($filePath);
echo "Deleted: $filePath\n";
}
}
}

closedir($dir);
} else {
echo "Directory does not exist: $directory\n";
}
}

echo "Cleanup complete.\n";
?>
__________________
SOMETHING EXTREME IS COMING SOON!
Publisher Bucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote