From cfb19915b53f135c6383b07b1899ad52cdf7b91c Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Sat, 20 Oct 2018 21:08:44 +0200 Subject: [PATCH] Optimized find query to only search within each users tmp directory --- var/www/find_old.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/var/www/find_old.php b/var/www/find_old.php index 762d978..c60f6ca 100644 --- a/var/www/find_old.php +++ b/var/www/find_old.php @@ -6,15 +6,14 @@ try{ die('No Connection to MySQL database!'); } -//delete tmp files older than 24 hours -exec('find /home -path "/home/*/tmp/*" -cmin +1440 -delete'); - //delete unused accounts older than 30 days $del=$db->prepare('UPDATE users SET todelete=1 WHERE id=?;'); $stmt=$db->prepare('SELECT system_account, id FROM users WHERE dateaddedexecute([time()-60*60*24*30]); $all=$stmt->fetchAll(PDO::FETCH_NUM); foreach($all as $tmp){ + //delete tmp files older than 24 hours + exec("find /home/$tmp[0]/tmp -path '/home/$tmp[0]/tmp/*' -cmin +1440 -delete"); if(filemtime("/home/$tmp[0]")>time()-60*60*24*30){ continue; }