Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Out of Inodes
PostPosted: Thu Oct 15, 2009 7:45 am 
Offline
Junior Member
User avatar

Joined: Mon Mar 02, 2009 10:45 pm
Posts: 38
My Linode has been running without incident for almost a year now, but recently I've been running out of inodes.

No substantial amount of hosted files have been added in several months. I can't seem to locate any directories (/tmp, etc) that are full of tiny, unused files.

Anyone out there run into this before? Anyone have tips on what may be safe to delete?

I can't fathom why I'm running out now because there have only been a few files added in recent months. The server hosts a forum, image gallery, and wordpress.

I'm not a linux expert, so if I've left out pertinent information let me know!

Thanks.


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 8:45 am 
Offline
Junior Member
User avatar

Joined: Mon Mar 02, 2009 10:45 pm
Posts: 38
Over 900,000 files are in /var/lib/php5. It is so large, that performing any operations on it seem to take forever (or never seem to return)...

Dunno if that helps.


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 11:52 am 
Offline
Senior Member

Joined: Mon Oct 12, 2009 1:20 am
Posts: 50
That is most likely your problem.

What are these files that are in there? If I were to take a guess, I would say that you have old session files that have built up in the "session" folder. For whatever reason they never got removed.

These files are safe to delete, so if you can't get into that folder to do work on it, just do rm /var/lib/php5/session/* from a different folder and see how long it takes to remove. If it takes a year and a half, then you know that was most likely your problem.

Your next step is then to figure out *why* your session files are not being cleaned up by php.


Last edited by arjones85 on Thu Oct 15, 2009 12:37 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 12:07 pm 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
arjones85 wrote:
rm * /var/lib/php5/session/ from a different folder

I hope people think before they copy and paste this one.


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 12:25 pm 
Offline
Senior Member

Joined: Mon Oct 12, 2009 1:20 am
Posts: 50
Stever wrote:
arjones85 wrote:
rm /var/lib/php5/session/* from a different folder

I hope people think before they copy and paste this one.



? What exactly is wrong with that command?

Do tell please.

In *my* /var/lib/php/session/ folder it contains nothing but session files. So I am running under the assumption that his folder is the same.


Last edited by arjones85 on Thu Oct 15, 2009 12:37 pm, edited 2 times in total.

Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 12:27 pm 
Offline
Senior Member

Joined: Mon Oct 12, 2009 1:20 am
Posts: 50
Double post.


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 12:31 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
arjones85 wrote:
Stever wrote:
arjones85 wrote:
rm * /var/lib/php5/session/ from a different folder

I hope people think before they copy and paste this one.



? What exactly is wrong with that command?

Do tell please.

In *my* /var/lib/php/session/ folder it contains nothing but session files. So I am running under the assumption that his folder is the same.


Follow the instructions for yourself:

cd /etc (The "from another directory" part)
rm * /var/lib/php5/session/ (the given command)

Wait, why is my /etc empty?

For those of you who are slow, "rm *" will delete the contents of the current directory...


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 12:38 pm 
Offline
Senior Member

Joined: Mon Oct 12, 2009 1:20 am
Posts: 50
Oops :oops: Bad typo. Fixed. I haven't had my coffee yet.

There was no -f flag so at least you still got fair warning you weren't doing what you intended to do.

:shock:


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 12:48 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
arjones85 wrote:
Oops :oops: Bad typo. Fixed. I haven't had my coffee yet.

There was no -f flag so at least you still got fair warning you weren't doing what you intended to do.

:shock:


I don't believe you'd get much of a warning if you were root, until it tried to delete a directory. And by then...


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 1:00 pm 
Offline
Senior Member

Joined: Mon Oct 12, 2009 1:20 am
Posts: 50
Yeah, I suppose you're right :oops: I forget that there's no alias to rm -i by default.


Top
   
 Post subject:
PostPosted: Thu Oct 15, 2009 2:40 pm 
Offline
Senior Member

Joined: Sat Mar 28, 2009 4:23 pm
Posts: 415
Website: http://jedsmith.org/
Location: Out of his depth and job-hopping without a clue about network security fundamentals
Guspaz wrote:
arjones85 wrote:
Oops :oops: Bad typo. Fixed. I haven't had my coffee yet.

There was no -f flag so at least you still got fair warning you weren't doing what you intended to do.

:shock:


I don't believe you'd get much of a warning if you were root, until it tried to delete a directory. And by then...

zsh will warn by default, if you have privileges.

_________________
Disclaimer: I am no longer employed by Linode; opinions are my own alone.


Top
   
 Post subject:
PostPosted: Fri Oct 16, 2009 9:34 am 
Offline
Senior Member

Joined: Thu Oct 08, 2009 5:07 pm
Posts: 99
Oops! Bad typo!

In a directory with a large amount of files, rm may not be able to cope (complains about argument list too long, a limitation of the shell I believe). Try this one (in the correct directory of course):

find . -name "*" -print | xargs rm -v


Top
   
 Post subject:
PostPosted: Fri Oct 16, 2009 12:50 pm 
Offline
Junior Member

Joined: Mon Nov 21, 2005 4:23 pm
Posts: 46
jonny5alive wrote:
find . -name "*" -print | xargs rm -v


At the risk of starting a command improvement match, I would personally do:

Code:
find /var/lib/php5/session | xargs rm -v


The '-name '*' -print' portion in not necessary since find with no other arguments will print all items on the specified path. If you want to be safe then you might do:

Code:
find /var/lib/php5/session -print0 | xargs -0 rm -v


The -print0 and -0 arguments are to make find print the list as 0-terminated strings, and for xargs to parse them as so. This gets around issues with filenames with spaces in them, or worse, filenames with newlines in them, a potential security risk.

edit: find's docs about file name handling.


Top
   
 Post subject:
PostPosted: Fri Oct 16, 2009 1:24 pm 
Offline
Senior Member

Joined: Fri Dec 07, 2007 1:37 am
Posts: 385
Location: NC, USA
Why all the gyrations?
Code:
find /wherever -delete


Top
   
 Post subject:
PostPosted: Fri Oct 16, 2009 5:00 pm 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
If you have tmpwatch installed, then you could edit /etc/cron.daily/tmpwatch and add:

Code:
if [ -d "/var/lib/php5/session" ]; then
    /usr/sbin/tmpwatch 24 /var/lib/php5/session
fi


Which (on a daily basis) will remove all session files that haven't been accessed in 24 hours. Adjust to your liking....

I'm not sure if tmpwatch will run into the same constraints as "rm" will when dealing with a huge number of files, but once you have the directory under control this is a way to ensure it doesn't happen again.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group