1
0

clean.sh 1.7 KB

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