| 123456789101112131415161718192021222324252627282930313233 |
- #!/bin/bash
- #########################################################################
- # Script for cleaning logs #
- # Created by DoIT #
- # ver 0.8 #
- #########################################################################
- echo -e "- \e[1;33mCleaning\e[0m [\e[1;35mhistory\e[0m]"
- HIS=$(find /home/ -name .bash_history | egrep "pmacko|doit")
- for h in $HIS; do rm -rf $h; done
- rm -rf /root/.bash_history
- test -d /opt/log2ram && rm -rf /opt/log2ram*
- history -c
- echo -e "- \e[1;33mCleaning\e[0m [\e[1;35mlogs\e[0m]"
- find /var/log/ -name "*-*" -type f -delete
- find /var/log/ -name "*.gz" -type f -delete
- find /var/log/ -name "*.log.*" -type f -delete
- find /var/log/ -name "*.[0-9]*" -type f -delete
- find /var/log/* -size +10M -exec rm -rf {} \;
- test -d /var/lib/clamav && rm -rf /var/lib/clamav/tmp*
- test -f /usr/local/bin/log2ram && systemctl restart log2ram > /dev/null 2>&1
- systemctl restart logrotate
- systemctl restart rsyslog
- echo -e "- \e[1;33mCleaning\e[0m package [\e[1;35marchives\e[0m]"
- test -f /usr/bin/apt && apt autoclean > /dev/null 2>&1
- test -f /usr/bin/apt && apt clean > /dev/null 2>&1
- test -f /usr/bin/apt && apt autoremove -y > /dev/null 2>&1
- test -f /usr/bin/yum && yum clean all > /dev/null 2>&1
- test -f /usr/bin/pip && /usr/bin/pip cache purge > /dev/null 2>&1
- test -f /usr/bin/pip3 && /usr/bin/pip3 cache purge > /dev/null 2>&1
- echo -e "- \e[1;33mCleaning\e[0m [\e[1;35mjournal\e[0m]"
- journalctl --vacuum-size=100M > /dev/null 2>&1
- echo -e "- \e[1;32mActual size\e[0m] of [\e[1;35mpartition\e[0m]"
- df -h | grep -v tmpfs | sed 's/ on//g'
|