Applicable to:
- Plesk for Linux
Symptoms
-
Session file folder for Plesk PHP is not auto cleaned;
-
Session file folder was changed from default
/var/lib/php/session/
, where XX is a PHP version:# grep -ir session.save_path /opt/plesk/php/*/etc/php.ini | grep -v ";"
/opt/plesk/php/5.6/etc/php.ini:session.save_path = " /var/lib/phpXX/session "
Cause
By design crontab task is configured to clean default session directory /var/lib/php/session/
:
# cat /etc/cron.hourly/plesk-php-cleanuper | grep php | grep -v "php.ini"
[ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && /usr/lib64/plesk-9.0/php_session_cleaner /var/lib/php/session $(/usr/lib64/plesk-9.0/maxlifetime)
Resolution
Apply one of the following solutions:
-
Log in to Plesk web interface
-
Open Plesk > Tools & Settings > PHP Settings and select the necessary PHP handler
-
Click on php.ini tab
-
Find
session.save_path
parameter and set it to/var/lib/php/session
For example, PHP 7.0:
-
Access the server via SSH
-
Go to Crontab directory:
# cd /etc/cron.hourly
-
Copy original task:
# cp plesk-php-cleanuper php70-cleaner
-
Edit the file php70-cleaner and include a new target directory:
FromCONFIG_TEXT: [ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && /usr/lib64/plesk-9.0/php_session_cleaner /var/lib/php/session $(/usr/lib64/plesk-9.0/maxlifetime)
to
CONFIG_TEXT: [ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && /usr/lib64/plesk-9.0/php_session_cleaner /var/lib/php70/session $(/usr/lib64/plesk-9.0/maxlifetime)
Comments
9 comments
How is the script called in Plesk 17? there is no such file in the cron.hourly!
Hello @Robert Kühn,
The file mentioned in the article belongs to root's crontab.
Please make sure that you are logged in as root or accessing the /etc/cron.hourly with sudo. Otherwise, you will see the crontab of the user you are logged in with.
Thank you @Nick Plekhov,
I just used the root user per ssh-console and even with sudo I can see only a ".placeholder" file inside. I just checked also the crontab with sudo and found only something like: /opt/psa/admin/bin/php -dauto_prepend_file=sdk.php '/opt/psa/admin/plib/modules/xovi/scripts/clear-cache.php' ..
Hello @Robert Kühn
In this case, I suggest you create the file manually.
The content should be as follows:
pgrep -f ".*$0$" | grep -qv $$ && exit 0
renice 19 -p $$ >/dev/null 2>&1
[ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && /usr/lib64/plesk-9.0/php_session_cleaner /var/lib/php/session $(/usr/lib64/plesk-9.0/maxlifetime)
After the file is created change the permissions as follows:
chmod 755 /etc/cron.hourly/plesk-php-cleanuper
Hello @Robert Kühn,
the cleanup script /usr/lib/php/sessionclean is called via /etc/cron.d/php in Plesk 17.
Same for /usr/lib/php5/sessionclean and /etc/cron.d/php5, but that one is broken in 17.8.
Hello,
I would like to ensure you, that /etc/cron.hourly/plesk-php-cleanuper is the cron script for PHP session path clean up in all Plesk Onyx versions.
ls: cannot access /etc/cron.hourly/plesk-php-cleanuper: No such file or directory
/usr/lib64/plesk-9.0 doesn't exist.
However this does: /usr/lib/plesk-9.0/php_session_cleaner
But there is no maxlifetime in /usr/lib/plesk-9.0/.
Product version: Plesk Onyx 17.8.11 Update #73
Anyway, I rewrote /usr/lib/php/sessionclean a bit so it cleans up plesk's default session dirs too, so that works for us.
Is it
/var/lib/phpXX/session or /var/lib/phpXX/sessions
does it matter?
Hello @highr0ll34,
Yes it's metter.
Using below command you should find what exactly custom path for "session.save_path" is set.
grep -ir session.save_path /opt/plesk/php/*/etc/php.ini | grep -v ";"
Found path must exist on the server.
This path must be used in point 4 of Resolution
Please sign in to leave a comment.