Millions of files in php's tmp error - how to delete?
Posted
by Jonatan Littke
on Server Fault
See other posts from Server Fault
or by Jonatan Littke
Published on 2010-04-19T18:12:53Z
Indexed on
2010/04/19
18:13 UTC
Read the original article
Hit count: 369
Hey.
I've got a tmp-folder with 14 million php session files in my home directory. At least that's what I think it is, it's not like I could ls
it or anything.
How can I empty this folder? I've tried using find
with the -exec rm {} \;
commands but that didn't work. ls 'sess_0*' | xargs rm
did neither.
I'm currently running rm -rf tmp
but after two hours the folder appears to be the same size.
REFERENCE INFO:
I suddenly encountered an error where SESSIONS could no longer be written to disk:
[Mon Apr 19 19:58:32 2010] [warn] mod_fcgid: stderr: PHP Warning: Unknown: open(/var/www/clients/client1/web1/tmp/sess_8e12742b62aa68a3f9476ec80222bbfb, O_RDWR) failed: No space left on device (28) in Unknown on line 0
[Mon Apr 19 19:58:32 2010] [warn] mod_fcgid: stderr: PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/www/clients/client1/web1/tmp) in Unknown on line 0
I ran:
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/md0 457G 126G 308G 29% /
tmpfs 1.8G 0 1.8G 0% /lib/init/rw
udev 10M 664K 9.4M 7% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
But as you can see, the disk isn't full.
So I had a look in the syslog which says the following 20 times per second:
kernel: [19570794.361241] EXT3-fs warning (device md0): ext3_dx_add_entry: Directory index full!
This led me thinking to a full folder, obviously, but since my web
folder only has 60k files (having counted them), I guessed it was the tmp
folder (the local one, for this instance of php) that messed things up.
Some commands I ran:
$ sudo ls sess_a* | xargs rm -f
bash: /usr/bin/sudo: Argument list too long
find . -exec rm {} \;
rm: cannot remove directory '.'
find: cannot fork: Cannot allocate memory
I'm running Debian Lenny, php5, ISPConfig, SuEXEC and Fast-CGI.
© Server Fault or respective owner