Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7441851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:04:59+00:00 2026-05-29T11:04:59+00:00

I have over 5 million session files in /var/lib/php5 I would like to delete

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:05:00+00:00Added an answer on May 29, 2026 at 11:05 am

    Let PHP’s gc perform cleanup by itself. Find php.ini and change session.gc_probability to something bigger, save it and restart Apache (call any php script). It says here http://somethingemporium.com/2007/06/obscure-error-with-php5-on-debian-ubuntu-session-phpini-garbage

    In Debian and Ubuntu, /var/lib/php5, where the session data is stored,
    has permissions of drwx-wx-wt and should only be cleaned by a cron
    script. So, the package maintainers disable automatic session garbage
    collection.

    Or you could try to put ini_set('session.gc_probability', 100); session_start(); (if your session.gc_divisor is equal to 100) in one of your scripts and call it. The best way is to put in empty php file, because it might perform cleanup for a very long period of time.

    ps: I would also try to leave session.gc_probability 1 and set session.gc_divisor to 1. It should call gc at every run, but you need it just for a directory cleanup.

    And check your cron /etc/cron.d/php5 – it should run every half an hour to purge session files in the /var/lib/php5/ directory.

    pps: found interesting comment

    This does not disable it (it is commented out). The default within the
    engine is still used – phpinfo() shows the value to be 1. There is a
    problem with garbage collection in Debian (and thus Ubuntu) but that’s
    due to PHP wanting to vacuum garbage that has already been removed by
    the cron script. This causes an error that may be displayed on the
    unlucky page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have over a million text files compressed into 40 zip files. I also
I have a dictionary in my database which has over million records and this
I have a table that has grown to over 1 million records... today (all
I have a file with a little over a million lines. {<uri::rdfserver#null> <uri::d41d8cd98f00b204e9800998ecf8427e> <uri::TickerDailyPriceVolume>
I have a tab-delimited file that has over 200 million lines. What's the fastest
I have a tab-separated data file with a little over 2 million lines and
Say if I have a large dataset, the table has well over a million
I have a model which looks like this: class Example (db.Model) : row_num =
I have a data structure that looks like this: Model Place primary key id
I have a table of over 1 million test score records that basically have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.