【问题标题】:Session Files Not Getting Cleaned Up [duplicate]会话文件未清理[重复]
【发布时间】:2011-10-14 06:58:39
【问题描述】:

可能重复:
cleanup php session files

很多会话文件似乎在我的会话文件夹 (/home/mysite.com/sessions) 中建立,即使会话过期也是如此。我需要手动清除这些吗?

我打算编写一个 cron 作业,但我不知道哪些会话文件处于活动状态,我不想将它们全部杀死。

【问题讨论】:

    标签: php session


    【解决方案1】:

    是的,您需要手动清理它们,因为您有 setup your own session save path。您可以检查文件的年龄并删除它是否超过 x 天/分钟:

    cd /path/to/sessions; find -cmin +24 | xargs rm
    

    取自php.ini的注释部分:

    ; NOTE: If you are using the subdirectory option for storing session files
    ;       (see session.save_path above), then garbage collection does *not*
    ;       happen automatically.  You will need to do your own garbage
    ;       collection through a shell script, cron entry, or some other method.
    ;       For example, the following script would is the equivalent of
    ;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
    ;          cd /path/to/sessions; find -cmin +24 | xargs rm
    

    请参阅这个相关/重复的问题:cleanup php session files


    “单个”命令:

    find /path/to/session -name sess_* -cmin +24 -exec rm {} \;
    

    【讨论】:

      猜你喜欢
      • 2010-10-13
      • 2014-12-31
      • 1970-01-01
      • 2015-07-05
      • 2015-03-13
      • 1970-01-01
      • 2015-04-16
      • 1970-01-01
      相关资源
      最近更新 更多