Cleaning /var/lib/php/sessions - 100% inodes usage - Ubuntu 16.04

After having issues doing anything on one of my Ubuntu 16.04 droplets due to disc usage errors, I found that I was running out of inodes and there are about 6.2m of them in /var/lib/php/sessions.

I recently updated from PHP 5 to PHP 7, I think this has caused the issue.

My questions are:

What’s the best way to clean sessions from this folder to free up inodes?

How can I prevent this from happening again?

I have this

09,39 *     * * *     root   [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi

in etc/cron.d/php but it doesn’t appear to be working.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

I believe that this is a good approach.

What happens if you try to run the script manually:


Do you get any errors?

Regards, Bobby