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.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!