Update setup_php_sessions.sh

fixed the php sessioncleaning script cron
This commit is contained in:
WhatTheServer
2020-09-07 09:22:08 -04:00
committed by GitHub
parent b6f324c7ef
commit 4593a68c5a

View File

@@ -10,8 +10,8 @@ mkdir -p /var/lib/lsphp/session/lsphp{53,54,55,56,70,71,72,73,74}
chmod -R 1733 /var/lib/lsphp/session/lsphp{53,54,55,56,70,71,72,73,74}
YUM_CMD=$(which yum)
APT_GET_CMD=$(which apt-get)
YUM_CMD=$(which yum 2> /dev/null)
APT_GET_CMD=$(which apt-get 2> /dev/null)
if [[ -n $YUM_CMD ]]; then
# Centos
@@ -36,11 +36,11 @@ fi
if [[ ! -e /usr/local/CyberCP/bin/cleansessions ]]; then
touch /usr/local/CyberCP/bin/cleansessions
chmod +x /usr/local/CyberCP/bin/cleansessions
cat >> /usr/local/CyberCP/bin/cleansessions <<-EOL
#!/bin/bash
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); find -O3 "/var/lib/lsphp/session/${version}" -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin "${session_time}" -delete; done
EOL
cat >> /usr/local/CyberCP/bin/cleansessions <<"EOL"
#!/bin/bash
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); find -O3 "/var/lib/lsphp/session/${version}" -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin "${session_time}" -delete; done
EOL
fi
# Create crontab only if not exist
@@ -49,7 +49,8 @@ command="/usr/local/CyberCP/bin/cleansessions >/dev/null 2>&1"
job="09,39 * * * * $command"
cat <(grep -i -v "$command" <(crontab -l)) <(echo "$job") | crontab -
echo "Checking cleansessions file"
cat /usr/local/CyberCP/bin/cleansessions
# Set to a 4 hour default as the 24 min default is kinda low and logs people out too often and as a global default in shared scenario its hard for clients to know how to override this while working in their admin area backends etc.
grep -Eilr '^memory_limit' --include=\*php.ini /usr/local/lsws/lsphp* | xargs sed -i -e "s/^session.gc_maxlifetime.*/session.gc_maxlifetime = '14400'/g"