1. When clean 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:tmpsess"
This means that the session cache is placed in the Level 2 directory in the tmpsess directory of D disk. Then you copy the multilevel directories generated by the above files to the d:tmpsess, and finally form a directory structure like this
D:tmpsessm5
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:tmpsess/s/d-7/C "cmd/c del @path" echo clearance System, LJ, complete! |
Copy the above content in txt Notepad to save. and modify the suffix to. bat, which is run in the scheduled task. The meaning of this sentence is to search d:tmpsess this directory, echo y|, to indicate that when you confirm, the command directly selects yes./s to include all subdirectories, d-7 represents 7 days ago files,/ c indicates the command to execute, note double quotes, 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:tmpsess/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 a subdirectory option that stores session files
(see above Session.save_path), then garbage collection does not * *
Occurs automatically. You will need to do your own garbage
Collect, through a shell script, cron item, or some other method.
For example, the following script will be the equivalent
Set Session.gc_maxlifetime 1440 (1440 seconds = 24 minutes):
CDS/paths//knots; found Cmin +24 | RM for Xargs
Personal experience,
We'd better reboot the server on a regular basis, and the server will be fast after restarting the server, so we can do a scheduled task to restart our server regularly.