I used the following to work out (with a bit of help from my colleague James) that we had a massive number of PHP session files which needed to be deleted on one machine:
1. How many inodes have I got in use?
root@polo:/# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 524288 427294 96994 81% /
none 256054 2 256052 1% /sys/fs/cgroup
udev 254757 404 254353 1% /dev
tmpfs 256054 332 255722 1% /run
none 256054 3 256051 1% /run/lock
none 256054 1 256053 1% /run/shm
none 256054 3 256051 1% /run/user
2. Where are all those inodes?
root@polo:/# find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
[...]
1088 /usr/src/linux-headers-3.13.0-39/include/linux
1375 /usr/src/linux-headers-3.13.0-29-generic/include/config
1377 /usr/src/linux-headers-3.13.0-39-generic/include/config
2727 /var/lib/dpkg/info
2834 /usr/share/man/man3
416811 /var/lib/php5/session
root@polo:/#
That's a lot of PHP session files on the last line.
3. How to delete all those files?
Delete all files in the directory which are older than 1440 minutes (24 hours):
root@polo:/var/lib/php5/session# find ./ -cmin +1440 | xargs rm
root@polo:/var/lib/php5/session#
4. Has it worked?
root@polo:~# find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
[...]
1088 /usr/src/linux-headers-3.13.0-39/include/linux
1375 /usr/src/linux-headers-3.13.0-29-generic/include/config
1377 /usr/src/linux-headers-3.13.0-39-generic/include/config
2727 /var/lib/dpkg/info
2834 /usr/share/man/man3
2886 /var/lib/php5/session
root@polo:~# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 524288 166420 357868 32% /
none 256054 2 256052 1% /sys/fs/cgroup
udev 254757 404 254353 1% /dev
tmpfs 256054 332 255722 1% /run
none 256054 3 256051 1% /run/lock
none 256054 1 256053 1% /run/shm
none 256054 3 256051 1% /run/user
root@polo:~#
Luckily we had a sensu alert emailing us that our inodes were almost used up.