Clean Inodes on Linux

This morning i just got alarm on our system monitoring said that inodes on one of server had 5% left space, then check disk with df -h there had not disk space issue, aha this wierd, then try to read more detail about the alarm and it said no disk space issue but inodes space issue, you have to know what different disk and inodes once.

To cehck inodes had different command on linux to check the disk, you can running this command to check inodes :

df -i

and it will showing like this

# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda3 671744 640908 30836 96% /var
/dev/sda4 3662848 584548 3078300 16% /home
tmpfs 507592 4 507588 1% /run/user/1033
1263/3965MB 0.34 0.54 0.50 1/141 20462

on the print command above said that /var had 96% inodes usage, so next we have to search where path inodes that have a lot files.

just run this command to find a lot files :

# for i in /var/*; do echo $i; find $i |wc -l; done

On the result command above said that /var/lib had a lot files, but we still don’t know exactly what path folder, so we have to check again on /var/lib/ with this command :

# for i in /var/lib*; do echo $i; find $i |wc -l; done

And the result above said /var/lib/php5 had a lot files, so we have to re-check again the path folder that had a lot files.

# for i in /var/lib/php5/*; do echo $i; find $i |wc -l; done
the result said :

After we checcked folder /var/lib/php5/sessions there were many files, so we sure that this path folder that had many files, so to clean up the /var/lig/php5/sessions just running this command :

First we have to know that we on the right path to delete the files, if you on wrong path folder this will make a big issue, you would be on fired ๐Ÿ˜€

find . -mtime +7 -exec stat -c "%n %y" {} \;</li>
find . -mtime +7 -exec rm {} \;</li>

the command above will delete file 7day before.

And We hope it will solve your issue ๐Ÿ™‚

Noted :
This will not worked fo you, so we won’t be responsible if there is Error on you OS!

Please follow and like us:

Leave a Reply

Your email address will not be published. Required fields are marked *