Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I safely delete all content in /var/lib/php5?

Tags:

php

session

I have over 5 million session files in /var/lib/php5 I would like to delete all files in this folder using rm *, however I'm not sure if there are other files other than the session files in that directory that should not be deleted.

Through SSH it took a few minutes to make the file count and I'm not sure I can navigate through there with all these random filenames. The setup is ubuntu lucid linx, apache 2 and php5. In the most common of setups are there other folders / files in /var/lib/php5 that I should not delete?

Edit The reason I want to remove the files is because I moved session handling to a database and don't need any of the files anymore.

like image 251
Moak Avatar asked Feb 09 '12 05:02

Moak


People also ask

How do I delete a session file?

If you use file driver for session, just remove those files in storage/framework/sessions . In config/session. php you can find lifetime , default it's set for 2 hours. After 2 hours it's automatically removed.

Where are PHP session files stored?

PHP Session Start By default, session data is stored in the server's /tmp directory in files that are named sess_ followed by a unique alphanumeric string (the session identifier).


1 Answers

cd /var/lib/php5
find . -name "sess_*" -print | xargs rm -v
like image 124
Aaron Shafovaloff Avatar answered Sep 21 '22 18:09

Aaron Shafovaloff