Plesk

The PHP session cleaner cron task in Plesk fails: run-parts: /etc/cron.hourly/plesk-php-cleanuper exited with return code 1

Symptoms

Cause

The cron script fails to execute becase /var/lib/php/sessions and /var/lib/php directories are missing on the server:

# ls -la /var/lib/php
ls: cannot access '/var/lib/php': No such file or directory
# ls -la /var/lib/php/sessions
ls: cannot access '/var/lib/php/sessions': No such file or directory

Resolution

  1. Connect to the server via SSH.

  2. Create missing /var/lib/php and /var/lib/php/sessions directories:

    # mkdir /var/lib/php
    # mkdir /var/lib/php/sessions

  3. Set the correct permissions for these directories:

    # chmod 755 /var/lib/php
    # chmod 1733 /var/lib/php/sessions

To verify the execution of the `plesk-php-cleanuper` cron task

  • Run the command below to execute task manually:

    # sh -x /etc/cron.hourly/plesk-php-cleanuper

  • After the execution is finished, check the exit code via the command below. It should be 0 which means success:

    # echo $?
    0