If your /tmp is too small, then you will face /tmp full issue. cPanel by default create /tmp with 512mb space. For a shared hosting server, 512MB-2GB is too small. If you face /tmp full issue, you can clear your tmp using tmpwatch. Also, you can remove the session file.
First, we need to install tmpwatch:
For CentOS/AlmaLinux:
yum install tmpwatch -y
For Ubuntu/Debian OS:
apt install tmpreaper -y
once tmpwatch is installed run the following command:
For CentOS/AlmaLinux:
/usr/sbin/tmpwatch --mtime --all 6 /tmp
For Ubuntu/Debian OS:
/usr/sbin/tmpreaper --mtime --all 6 /tmp
This will delete all files over 6 hours old. We can configure the cronjob to automate this process.
from SSH type:
EDITOR=nano crontab -e
Go to the very bottom and paste:
For CentOS/AlmaLinux:
0 */2 * * * /usr/sbin/tmpwatch --mtime --all 6 /tmp
For Ubuntu/Debian OS:
0 */2 * * * /usr/sbin/tmpreaper --mtime --all 6 /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 files using the following command.
cd /tmp && rm -f sess_*