Now can only be manually cleaned and divided into multi-level directory storage. At least I can mitigate I/O pressure. The following method allows you to schedule tasks with the system. Run it once a week. Empty cookies seven days ago
First, use PHP to automatically create a two-level directory such as this sort of directory/1/b/or A/1/, which is cached in numbers and letters. PHP statements are as follows
| The code is as follows |
Copy Code |
|
<?php
Error_reporting (E_all & ~e_notice);
$string = ' 0123456789abcdefghijklmnopqrstuvwxyz ';
$length = strlen ($string);
for ($i = 0; $i < $length; $i + +) {
for ($j = 0; $j < $length; $j + +) {createfolder (' d:/pc_webserver/phproot/v8/data/'. $string [$i]. ' /'. $string [$j]);
}
}
function CreateFolder ($path) {
if (!file_exists ($path)) {
CreateFolder (DirName ($path)); Back to the directory section in the path
mkdir ($path, 0777);
}
}
?> |
Then, modify the php.ini file on the server. Search for the word session.save_path
Modified to Session.save_path = "2;d:/tmp/sess"
This means that the session cache is placed in the Level 2 directory in the tmp/sess directory of D disk. Then you copy the multilevel directories generated by the above files to the d:/tmp/sess, and finally form a directory structure like this
d:/tmp/sess/m/5/
Then the sess is automatically generated in the inside. Of course, the system will not be able to automatically clean up this junk file after this classification. It's manual.
| The code is as follows |
Copy Code |
|
@echo off
Echo is purging files, please wait ...
Echo y| forfiles/p d:/tmp/sess/s/d-7/C "cmd/c del @path"
echo clearance System, LJ, complete! |
Copy the above contents in txt Notepad to save. and modify the suffix to. bat, and run the scheduled task. The meaning of this sentence is to search d:/tmp/sess this directory, echo y|, to indicate that when you confirm, the command directly selects yes./s to include all subdirectories, d-7 represents the file 7 days ago. ,/C indicates the command to execute, with double quotes, and Del to clear the previous directory. If you add a m/as the following sentence, it means that only files with a rar suffix are deleted. Otherwise, delete all.
| The code is as follows |
Copy Code |
|
Echo y| forfiles/p d:/tmp/sess/s/M *.rar/d -7/c "cmd/c del @path" |
Here is an explanation given in the php.ini
After this number of seconds, the stored data will be treated as "garbage",
Clean up the garbage collection process.
session.gc_maxlifetime = 1440
Note: If you are using subdirectory options for storing session files
(see session.save_path above), then garbage collection does not * * *
occurs automatically. You will need to do your own garbage
collection, through a shell script, cron item, or some other method.
For example, the following script will be equivalent to
set Session.gc_maxlifetime 1440 (1440 seconds = 24 minutes):
CD/path//section; Find Cmin +24 | Xargs rm