时间:2021-07-01 10:21:17 帮助过:4人阅读
修改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 will 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; do for x in $i; do 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 定时任务: [root@hz scripts]# echo '#This is a config php session BY:BYRD AT:2015-11-12' >>/var/spool/cron/root [root@hz scripts]# echo '0 3 * * 0 /bin/bash /byrd/scripts/spehspsion.sh >/dev/null 2>&1' >>/var/spool/cron/root
总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
PHP文件下载中文文件名乱码
php中常见的排序算法
PHP判断手机是IOS还是Android的三个方法
以上就是如何设置php实现session定期自动清理的详细内容,更多请关注Gxl网其它相关文章!