Plesk

Session file folder in Plesk PHP is not auto cleaned

Symptoms

PHP session files in folder /var/lib/php/session/are not removed automatically.

Cause

Session file folder was changed from default /var/lib/php/session/:

# grep -ir session.save_path /opt/plesk/php/*/etc/php.ini | grep -v ";"
/opt/plesk/php/7.4/etc/php.ini:session.save_path = "/var/lib/php74/session"

Resolution

Apply one of the following solutions:

Change the current PHP session folder to default one in Plesk UI

  1. Log into Plesk)

  2. Open Tools & Settings > PHP Settings and select the PHP handler with changed session.save_path value

  3. Click on php.ini tab

  4. Find session.save_path parameter and set it to /var/lib/php/session

Create scheduled tasks for different PHP session directories

  1. Access the server via SSH

  2. Copy original task:

    # cp /etc/cron.hourly/plesk-php-cleanuper /etc/cron.hourly/php74-cleaner

  3. Edit the file php74-cleaner and change the last line to the following:

    [ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && /usr/lib64/plesk-9.0/php_session_cleaner /var/lib/php74/session $(/usr/lib64/plesk-9.0/maxlifetime)

Exit mobile version