Clean Sessions

day by day, new problems with CyberPanel come up all the time…
Today I would just like to point out this problem that was already reported in 2010, but is still present… Absurd!

The file is /usr/local/CyberCP/bin/cleansessions, this have syntax and value’s problem.

If you’re here because you’re trying to fix the problem, replace the contents of that file with this:

for version in $(ls /usr/local/lsws|grep lsphp); do echo ""; echo "PHP $version"; session_time=$(($(/usr/local/lsws/${version}/bin/php -i |grep -Ei 'session.gc_maxlifetime'| grep -Eo "[[:digit:]]+"|sort -u) / 60)); find -O3 "/var/lib/lsphp/session/${version}" -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin +"${session_time}" -delete; done