After the configuration completes PHP, the default PHP will generate session into the/tmp directory, resulting in a lot of/tmp directory files, so the session needs to be periodically cleaned up:
Modify PHP.ini:
[Root@hz scripts]# grep "Session.save_path ="/usr/local/php/lib/php.ini
; Session.save_path = "N;/path"
; Session.save_path = "N; Mode;/path "
; Session.save_path = "/tmp"
Session.save_path = "2;/tmp/session"
[Root@hz ~]# cat/byrd/script/cleartmpsen.sh
#!/bin/bash
# version:1.0
# Author:byrd
# Site:www.t4x.org
# contact:root#t4x.org
# This is script would clear PHP session before 3 hours.
i= "0 1 2 3 4 5 6 7 8 9 a B c D E F"
For Byrd in $i;
Todo
for x in $i;
Todo
Mkdir-p/tmp/session/$byrd/$x;
Done
Done
Chown-r bywww:bywww/tmp/session
Chmod-r 1777/tmp/session
Find/tmp/session-amin +180-exec RM-RF {}\;
If [' grep ' Session.save_path = '/usr/local/php/lib/php.ini | wc-l '-eq 3];then
Sed-i ' S#;session.save_path = '/tmp ' #;session.save_path = '/tmp ' \nsession.save_path = ' 2;/tmp/session ' #g '/usr/local/ Php/lib/php.ini
Else
Exit 1
Fi
Timed task:
[Root@hz scripts]# Echo ' #This is a config php session by:byrd at:2014-03-31 ' >>/var/spool/cron/root
[Root@hz scripts]# echo ' 0 3 * * 0/bin/bash/byrd/scripts/spehspsion.sh >/dev/null 2>&1 ' >>/var/spool/cro N/root
Note: Because this configuration modifies php.ini, the PHP process needs to be restarted.