i'm actually working on a Linux environnement and i have some problem with files in my tmp folder, lots of file were created tonight with a 0 size, we managed to purge them this morning but a question remain, the . of the directory is around 21 mb which doesn't seems right, is there any ways to have an explanation of what's inside and how to reset its size to a more common one?
$ls -al
total 87644
drwxrwxrwt 3 root root 21905408 Dec 5 11:06 .
drwxr-xr-x 30 root root 4096 Dec 4 22:10 ..
this morning we had like nine millions files in this directory, i think that it's some database which store filename or logs of the directory, can someone light up this point for me? Thanks
I don't think a directory ever reduces in size on its own although it may for certain filesystem types (none that I know of, though). In other words, it stays at whatever its peak size was.
If you want to reduce it, the simplest way is often to create a new directory in the same location as the old, move the files across, then delete the old and rename the new to replace it.
You may have to do this in single-user mode if your system is an important one, so as to minimise the possibility of affecting other users. If it's solely your box, you can probably get away with just doing it when little else is running.
Here's the starting point for the
/tmp
directory:Then you can check to ensure
/tmp_old
is empty before removing it completely.Another possibility would be to try:
This will hopefully preserve open files (inodes) though in the
/tmp_old
directory, with new temporary files being created in your brand new (smaller) directory. Then just reboot your box (cleanly) if possible and remove the/tmp_old
directory.You may want to check the permissions of your current
/tmp
directory to ensure you set them correctly for your new one.