Skip to content

Commit 2155fb1

Browse files
committed
Fixed: FS#1006 - PHp is not removing session files from sesssion temp dir
1 parent 033c801 commit 2155fb1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

server/cron_daily.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,23 @@ function setConfigVar( $filename, $varName, $varValue ) {
175175
}
176176
}
177177

178+
#######################################################################################################
179+
// Cleanup website tmp directories
180+
#######################################################################################################
181+
182+
$sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ".$conf["server_id"];
183+
$records = $app->db->queryAllRecords($sql);
184+
if(is_array($records)) {
185+
foreach($records as $rec){
186+
$tmp_path = realpath(escapeshellcmd($rec["document_root"].'/tmp'));
187+
if($tmp_path != '' && strlen($tmp_path) > 10 && is_dir($tmp_path)){
188+
exec("cd ".$tmp_path."; find -ctime +1 -user ".escapeshellcmd($rec['system_user'])." | grep -v -w .no_delete | xargs rm &> /dev/null");
189+
exec("cd ".$tmp_path."; find -ctime +1 -user www-data | grep -v -w .no_delete | xargs rm &> /dev/null");
190+
exec("cd ".$tmp_path."; find -ctime +1 -user wwwrun | grep -v -w .no_delete | xargs rm &> /dev/null");
191+
}
192+
}
193+
}
194+
178195
#######################################################################################################
179196
// Cleanup logs in master database (only the "master-server")
180197
#######################################################################################################

0 commit comments

Comments
 (0)