Tuesday, October 4, 2022

Untuk clear log dan lain" di CyberPanel [GUIDE] Logs Cleaner for CyberPanel

https://community.cyberpanel.net/t/guide-logs-cleaner-for-cyberpanel/37324

I recently had a serious problem with the logs, the switchLSWSStatus file weighed over 700GB. Therefore I decided to share my script with you to always keep the server logs clean.

FOLLOW MY GUIDE

sudo -i
cd /root/
nano logscleaner.sh

Paste this code:

#!/bin/bash
# Software Logs Cleaner v1.0alpha, use only for test
# Powered by Nicholas Sciortino

# 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 logscleaner.sh

Now you can run it manually with the command, after you have cleared all logs and freed up a lot of memory ^^

sh logscleaner.sh

We can also automate cleanup using a cron

crontab -e

At the end of the file add

0 0 * * 0 sh /root/logscleaner.sh

Once a week the script will be executed which will delete all the logs