How to clear /tmp on Centos/cPanel server

If your /tmp is too small, then you will face /tmp full issue. cPanel by default create /tmp with 512mb space. For shared hosting server 512mb is too small. However, we will teach you “how to increase /tmp size” on our next tutorial.

If you face /tmp full issue, you can clear your tmp using tmpwatch. Also you can remove session file.

First wee need to install tmpwatch.

yum install tmpwatch -y

once tmpwatch is installed run following command-

/usr/sbin/tmpwatch --mtime --all 24 /tmp

This will delete all files over 24 hours old. We can configure cronjob to automated this process.

from SSH type:

crontab -e

Go to the very bottom and paste

0 4 * * * /usr/sbin/tmpwatch –mtime –all 24 /tmp

then press Control+X you will get confirmation do you want to save. Type Y for yes, and press enter.

Also we can delete session file using following command.

# cd /tmp
# rm -rf sess_*

Leave a Reply

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

*
*

*