How to delete cache every 5 minutes programmatically in Magento 2

First of all create a custom php file in root directory. For example test.php How to delete cache every 5 minutes programmatically in Magento 2expoundsofttechsolution How to delete cache every 5 minutes programmatically in Magento 2 And then paste the following code to this file(root directory in pub folder):
<?php

use Magento\Framework\App\Bootstrap;
include('../app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();


echo "test";


And check to run this file in your browser with this type of URL:
https://your-domain.com/test.php
if the browser print test, then understand that the file is running properly. And paste the following code to test.php file:
<?php
//echo $rootPath = $_SERVER['DOCUMENT_ROOT'];
$dirpath=realpath(dirname($_SERVER['PHP_SELF']));
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('../var/cache/'));

$files = array();
$iii=0;
foreach ($rii as $file) {

    if ($file->isDir()){
continue;
       
    }
$url = $file->getPathname();
}
?>

<?php



/*
 * php delete function that deals with directories recursively
 */
function delete_files($target) {
    if(is_dir($target)){
        $files = glob( $target . '*', GLOB_MARK ); 

        foreach( $files as $file ){
            delete_files( $file );      
        }
        rmdir( $target );
    }  elseif(is_file($target)) {
        unlink( $target );  
    }
}

delete_files('../var/cache/');
echo "done";
?>
if the browser print done, then understand that the cache folder is deleted successfully.
After it run this file in cron with settings to select run every 5 minutes.