π§Ή CyberPanel Server Cleanup: Logs, Dumps, Backups in One Shot
π Introduction
This guide is your go-to reference for keeping a CyberPanel + OpenLiteSpeed Linux server lean, fast, and clean. Over time, logs, backups, and core dumps pile up β wasting space, slowing down services, or even crashing the server.
Use these commands and tips to clean:
- π§ Web server logs
- π₯ Crash/core dumps
- π¦ Backups
- π System journal logs
π Web Server Logs Cleanup (/usr/local/lsws/logs)
π Location:
/usr/local/lsws/logs/
π§Ύ Files:
access.log,error.log,stderr.log.log.*,.gz,.bak(rotated logs)
π§Ή Clean all logs:
rm -f /usr/local/lsws/logs/*.{log,log.*,gz,bak}
π₯ Core Dump Cleanup (/etc/coredumps)
π Location:
/etc/coredumps/
π§ What are they?
Core dumps are memory snapshots saved when an app crashes. Useful for debugging but take up huge space.
π§Ή Keep only the latest 5 dumps:
ls -lt /etc/coredumps | tail -n +6 | awk '{print $9}' | xargs -I{} rm -f /etc/coredumps/{}
π Disable dumps (recommended):
echo 'kernel.core_pattern=|/bin/false' >> /etc/sysctl.conf
sysctl -p
echo '* hard core 0' >> /etc/security/limits.conf
π¦ Backup Folder Cleanup (/backup)
π Location:
/backup
ποΈ Whatβs inside?
CyberPanel stores scheduled and manual backups here β easily fills disk space.
π§Ή Keep only the 2 most recent backups:
ls -dt /backup/* | tail -n +3 | xargs -I{} rm -rf {}
ποΈ Systemd Journal Cleanup
π Location:
/var/log/journal/
π§ What is it?
System log storage managed by systemd. It can quietly consume multiple gigabytes.
π§Ή Delete logs older than 1 day:
journalctl --vacuum-time=1d
βοΈ Full Cleanup (One-Line Command)
π‘ Run this to clean everything in one go:
ls -lt /etc/coredumps | tail -n +6 | awk '{print $9}' | xargs -I{} rm -f /etc/coredumps/{} && rm -f /usr/local/lsws/logs/*.{log,log.*,gz,bak} && ls -dt /backup/* | tail -n +3 | xargs -I{} rm -rf {} && journalctl --vacuum-time=1d