Steps to clean /temp on CentOS/ cPanel Server

There are instances when you are unable to connect to ssh due to disk space being full in tmp, reboot the server in cloud server manager and then try again.

Upon getting connected,run the following command:

yum install tmpwatch -y

Upon successfully installing tmpwatch, run the following command in order to delete all the old files over 12 hours old.

/usr/sbin/tmpwatch -am 12 /tmp

STEPS TO CONFIGURE YOUR SERVER TO REMOVE TMP FILES AUTOMATICALLY:

1] From SSH type

crontab -e

2] Paste at the very bottom

04***/usr/sbin/tmpwatch -am 12 /tmp

3] Press CTRL+X on PC and Command+X on MAC. Pop for confirmation will appear. Type   'Y' for Yes, and then press Enter.

Location for crontab for root is /var/spool/cron. So that you can add the line by using CSE.

Session file can be removed using the following command:

# cd /tmp
# rm -rf sess_*
Was this answer helpful? 0 Users Found This Useful (0 Votes)