-1

I have a CentOS web server with many clients on it. I see the /tmp reached DISKCRITICAL just after about two months since I made 8 GB (after expansion from 4 GB)! I want to know the reasons that make tmp getting full so quickly, and how to clean it up safely? I read a lot about expanding it and deleting some expired files before but it didn't success!

Aymen
  • 1
  • 1
  • 3
    Please show us what you actually tried and why it didn't work. – Julie Pelletier Jun 13 '16 at 06:24
  • Thankd for your interset, To empty some, space I tried to delete files begin with sess_ in /tmp , but all of theme have small sizes. So, I expanded the /tmp to 8 GB using this tutorial https://www.vps.net/community/knowledgebase/display/vpsfeatures/How+to+increase+tmp+partition+size. Now, /tmp reached DISKCRITICAL again! – Aymen Jun 13 '16 at 09:35
  • Based on the fact that you tagged `web-server`, is it possible that these are just session files? What do the file names look like? – Julie Pelletier Jun 13 '16 at 18:12
  • Yes, they were regular session files, but all of them are small in size. I think there is another issue. – Aymen Jun 14 '16 at 05:36
  • It is normal for session files to be small, but you should check your php.ini session settings (mainly `session.gc_maxlifetime`) to correct the `garbage collector` (`gc` aka ) automatic cleanup. – Julie Pelletier Jun 14 '16 at 05:42
  • session.gc_maxlifetime = 1440 which is in default settings. I see there are a lot of session files generated in my tmp directory. Is it safe to less the gc? What is the recommend value to do so? Thanks – Aymen Jun 16 '16 at 23:06
  • It depends on the application. Bank sites have sessions of around 15 minutes while some sites will maintain the session for days. That said, I'm really curious as to why you'd accumulate many session files over months. You should check `session.gc_probability`, `session.gc_divisor` or see if your system is set up to use a cron job that fails for any reason. – Julie Pelletier Jun 17 '16 at 00:27
  • I see them session.gc_probability = 1 and session.gc_divisor = 1000, I will make session.gc_divisor = 100 to make the session files deleted more rapidly. Any another advise? – Aymen Jun 17 '16 at 11:56
  • Look at the files. Like I said it doesn't make sense that they'd accumulate over months if this is set. Maybe you're not looking at the right php.ini, maybe the files are not what you think, maybe your application keeps thousands of people logged all the time. Talk to your web developers. – Julie Pelletier Jun 17 '16 at 14:36

1 Answers1

5

I find Scientific Method the perfect tool for a job like this.

  1. Problem Statement

My /tmp directory is getting full

  1. Gather information

    • Using suitable tools find out what is filling the /tmp directory. I find ls(1) and perhaps du(1) great tools for this job. Maybe even lsof(8) will be useful.
  2. Analyse the information you have gathered.

    • What files are filling the disk?
    • What generates the files ?
    • Why are they generated ?
    • Why are they in /tmp ?
  3. Identify solutions an take remedial action. This is very dependent on (3) above.

  4. Monitor your changes in (4) above.

  5. Did the changes fix the problem ? Is it better? Is it worse ? Is there no difference ? Where you go from here depends on what you find. You may need to go back to 2. and gather more pertinent data or 3. to reanalyse what data you have or 4. because you identified a number of potential solutions.

  6. Document your findings and the changes you made.

  7. Done.

user9517
  • 115,471
  • 20
  • 215
  • 297
  • Thanks for your valuable information, But have tried specific steps to solve the above issue? – Aymen Jun 13 '16 at 09:40
  • 1
    There are no specific steps ... You (or someone else) will have to analyse what is going on and take appropriate action. – user9517 Jun 13 '16 at 09:46
  • I just wanted to see your experiment to handle the above problem! Thanks again. – Aymen Jun 14 '16 at 05:33
  • My experiment would be exactly what I said in my answer. What is found at 3 informs 4. I mean we could guess and I would guess [Hot Java has gone cold](http://pages.cs.wisc.edu/~ballard/bofh/bofhserver.pl) but why guess when it should be fairly easy to figure out exactly. – user9517 Jun 14 '16 at 06:14