PHP Script uses bash command to find file created within mins ago

$dir        = "/home/ec2-user/julius/tmp/";
$file_type  = "json";
$min        = "5";  #Created How Many Min Ago
$output     = shell_exec("find $dir -cmin -$min -type f -name '*.$file_type'");

$json_file  = explode("\n",$output);
array_pop($json_file); # To remove last \n

if(empty($json_file)){exit();}
print_r($json_file);


You may also like...