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.
15 Replies
Dunno if that helps.
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.
@arjones85:
rm * /var/lib/php5/session/ from a different folder
I hope people think before they copy and paste this one.
@Stever:
@arjones85: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.
@arjones85:
@Stever:
@arjones85: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…
There was no -f flag so at least you still got fair warning you weren't doing what you intended to do.
@arjones85:
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…
@Guspaz:
@arjones85: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.
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
@jonny5alive:
find . -name "*" -print | xargs rm -v
At the risk of starting a command improvement match, I would personally do:
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:
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
find /wherever -delete
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.
mv /var/lib/php5/session /var/lib/php5/session.old
mkdir /var/lib/php5/session
chmod 777 /var/lib/php5/session
chmod +t /var/lib/php5/session
rm -r /var/lib/php5/session.old