douchungu0859 2016-04-22 03:37
浏览 475

设置php sessionclean cron作业在chroot环境中运行

I have multiple PHP-FPM chroot sites that need to run the sessionclean cronjob. I found this gist here:

https://gist.github.com/zerthimon/4e15f4d04c888dee0410

Which has this edit of the /etc/cron.d/php file

*/30 * * * *     root   [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/www/pools ] && find /var/www/pools -path "*/var/lib/php5" -exec /usr/lib/php5/sessionclean {} $(/usr/lib/php5/maxlifetime) \;

First to note is that I am running php7, so php5 becomes php. Second note is that I have no maxlifetime in /usr/lib/php so am trying to run this without. Here is my modification which is not working:

 [ -x /usr/lib/php/sessionclean ] && [ -d /var/www/html ] && find /var/www/html -path "*/var/lib/php" -exec /usr/lib/php/sessionclean {} \;

Can someone please tell me how to modify the above to parse through each /var/www/html/[chroot]/var/lib/php/sessions directory to remove sessionfiles that are not currently being used?

Thank You.

  • 写回答

1条回答 默认 最新

  • douqiao8370 2016-04-22 12:54
    关注

    I came up with a workaround. This does not directly modify the /etc/cron.d/php file, but does offer a solution for people wanting to clear session files no longer in use within chrooted php-fpm environments.

    A tiny script runs every 4 hours in crontab.

    #!/bin/bash
    
    cd /var/www/html
    for D in *; do
    find /var/www/html/"$D"/var/lib/php/sessions/sess_* -mmin +240 -delete;
    done
    

    This will delete all session files not modified within the last 4 hours which are stored within each chroot environment.

    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决