Question

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

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

I believe that this is a good approach.

What happens if you try to run the script manually:

/usr/lib/php/sessionclean

Do you get any errors?

Regards, Bobby