This was happening a lot on my main server (RHEL Linux with cPanel). Ever since I chose a cPanel installation, the /tmp directory was often spiking to 100%. The mistery was that I couldn’t list the files to see the cause of those spikes in /tmp usage. Regular ‘ls’ command was showing files, but nothing alarmingly big, and nowhere close to 1G that I had allocated to /tmp.
I first changed a temporary directory for my Web applications. Instead of /tmp I used /tmp-sc, and fixed my applications accordingly. When /tmp goes to 100% at least my applications were able to use a disk cache.
Next, I decided to have MySQL use /tmp-mysql. Created a new directory with proper permissions and added a tmpdir option to mysqld section of /etc/my.cnf
tmpdir = /tmp-mysql
I restarted MySQL and voila, all my troubles were gone.
The server with 2GB of ram and 2 cores now serves over 1 million PHP pages + many many more static images and the best part is that the load on the server rarely goes above 1.
If you find this tip helpful, let me know.