Your /tmp is full and this is how to manually clean your /tmp files in WHM


Files in tmp/ can easily become very full and slow doen your sever. Whilst  the /tmp files are set to auto clean itself using the tmpwatch  sometimes it is good to manually clean it and adjust the cron settings to fit your server needs . There is a application called tmpwatch. “tmpwatch”  exist in a default install of CentOS. tmpwatch exists to handle the removal of “old” files from /tmp and other locations on the server. From the manpage for tmpwatch:

tmpwatch recursively removes files which haven’t been accessed for a given number of hours. Normally, it’s used to clean up directories which are used for temporary holding space such as /tmp.
if tmpwatch is already installed then skip to the next step 2

Step 1

Open SSH to your server, i.e ssh root@ipaddrsss  -p port number and you will asked for a password. enter the password.Note  if SSH will not connect due to disk space full in tmp, reboot your server in cloud server manager then try again.
Once connected run the following command to install tmpwatch if not already installed on your server.It is likely to have been installled on your server.

yum install tmpwatch -y


Once installed issue tis command to manually  clear everything in my /tmp directory older than 10days

/usr/sbin/tmpwatch 240 /tmp

Step 3

Issure the command

crontab -e

to configure your server to do this automatically. go to the very bottom and paste the command below

0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp

then press Control+X (on PC) or Command+x (on Mac) you will get confirmation do you want to save. Type Y for yes, and press enter

Step 4


Change the “12” to anything you want  12 is in hours 10days will be 240, 5 days will  120, etc


Solved-Your /tmp is full and this is how to manually clean your /tmp files in WHM




Alternative and safer.


Below is an alternative and appears to be safer

navigate to the tmpwatch using your ssh client, using the command below

[root@cpj ~]# cat /etc/cron.daily/tmpwatch 

/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
        -x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix 240 /tmp

/usr/sbin/tmpwatch "$flags" 720 /var/tmp

for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
    if [ -d "$d" ]; then
        /usr/sbin/tmpwatch "$flags" -f 720 "$d"

The first command without the excluded paths essentially looks like this:

/usr/sbin/tmpwatch -umc 240 /tmp

The “240” is the number of hours, which would be 10 days. If you want to have files removed from /tmp more frequently, you may try changing 240 to a lesser value. This would be more preferred than running a cron job that runs “rm -rf” on everything inside /tmp, as that could interfere with the MySQL and PostgreSQL sockets, and will interfere with EasyApache while it’s running.


About Author

Comments are closed.