91
Installation and Configuration / Re: Clearing cache automatically
« Last post by Basara on June 11, 2025, 01:39:32 AM »Hoping this message still gets some recognition. As this post is relevant to the problem we have with inodes filling up on our hosting site. However the script in this message is not a link just text. Anyone know where we can find this clear_cache.sh ?Hello.
Thank You,
Can you tell which version of AbanteCart you're using and the number of products you have?
You can create the clean_cache.php script like this
Code: [Select]
<?php
// File: /home/public_html/clean_cache.php
$cacheDir = __DIR__ . '/system/cache';
// Ensure the directory exists
if (!is_dir($cacheDir)) {
exit("Cache directory not found: $cacheDir\n");
}
$files = scandir($cacheDir);
foreach ($files as $file) {
// Keep index.html and skip . / ..
if ($file === '.' || $file === '..' || $file === 'index.html') {
continue;
}
$filePath = $cacheDir . '/' . $file;
if (is_file($filePath)) {
unlink($filePath);
} elseif (is_dir($filePath)) {
deleteDirectory($filePath);
}
}
// Recursive deletion function
function deleteDirectory($dir) {
$items = array_diff(scandir($dir), ['.', '..']);
foreach ($items as $item) {
$path = "$dir/$item";
is_dir($path) ? deleteDirectory($path) : unlink($path);
}
return rmdir($dir);
}
and set a CRON job to run it like
Code: [Select]
*/6 * * * * /usr/bin/php /home/public_html/clean_cache.php >/dev/null 2>&1