mirror of
https://github.com/DanWin/hosting.git
synced 2025-08-21 12:44:22 +02:00
Optimized find query to only search within each users tmp directory
This commit is contained in:
parent
d9e496930d
commit
cfb19915b5
1 changed files with 2 additions and 3 deletions
|
@ -6,15 +6,14 @@ try{
|
||||||
die('No Connection to MySQL database!');
|
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
|
//delete unused accounts older than 30 days
|
||||||
$del=$db->prepare('UPDATE users SET todelete=1 WHERE id=?;');
|
$del=$db->prepare('UPDATE users SET todelete=1 WHERE id=?;');
|
||||||
$stmt=$db->prepare('SELECT system_account, id FROM users WHERE dateadded<?;');
|
$stmt=$db->prepare('SELECT system_account, id FROM users WHERE dateadded<?;');
|
||||||
$stmt->execute([time()-60*60*24*30]);
|
$stmt->execute([time()-60*60*24*30]);
|
||||||
$all=$stmt->fetchAll(PDO::FETCH_NUM);
|
$all=$stmt->fetchAll(PDO::FETCH_NUM);
|
||||||
foreach($all as $tmp){
|
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){
|
if(filemtime("/home/$tmp[0]")>time()-60*60*24*30){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue