How to clean all log files in CP or CyberPanel
Login as root user via ssh or if you sudo user then type:
sudo -i (root user did not require this command)
cd /root/
nano clearlog.sh
Paste this code:
!/bin/bash
clear all logs of CP
rm -rf /usr/local/lsws/logs/*
clear OpenLiteSpeed cache folder
rm -rf /usr/local/lsws/cachedata
remove old CyberPanel versions
rm -rf /usr/local/*.tar.gz
clear other logs
rm -f /home/cyberpanel/switchLSWSStatus
rm -f /home/cyberpanel/stderr.log
rm -f /home/cyberpanel/error-logs.txt
After you have to give permissions to the executable file
chmod +x clearlog.sh
Now you can run it manually with the command, after you have cleared all logs and freed up a lot of memory ^^
sh clearlog.sh
We can also automate cleanup using a cron
crontab -e
At the end of the file add
TO run DAILY : 0 0 /root/clearlog.sh > /dev/null 2>&1
TO run Weekly : 0 0 0 /root/clearlog.sh > /dev/null 2>&1
TO run Monthly: 0 0 1 * /root/clearlog.sh > /dev/null 2>&1