clean.sh 1.1 KB

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. #########################################################################
  3. # Script for cleaning logs #
  4. # Created by DoIT #
  5. # ver 0.6 #
  6. #########################################################################
  7. echo -e "- [\e[1;33mCleaning\e[0m] logs and history"
  8. HIS=$(find /home/ -name .bash_history)
  9. for h in $HIS; do rm -rf $h; done
  10. rm -rf /root/.bash_history
  11. rm -rf /opt/log2ram*
  12. find /var/log/ -name "*.gz" -type f -delete
  13. find /var/log/ -name "*.log.*" -type f -delete
  14. find /var/log/ -name "*.[0-9]*" -type f -delete
  15. test -d /var/lib/clamav && rm -rf /var/lib/clamav/tmp*
  16. history -c
  17. echo -e "- [\e[1;33mCleaning\e[0m] APT archives"
  18. apt autoclean > /dev/null 2>&1
  19. apt clean > /dev/null 2>&1
  20. apt autoremove -y > /dev/null 2>&1
  21. pip cache purge > /dev/null 2>&1
  22. echo -e "- [\e[1;33mCleaning\e[0m] Journal"
  23. journalctl --vacuum-size=100M > /dev/null 2>&1
  24. echo -e "- [\e[1;32mActual size\e[0m] of partition"
  25. df -h | grep -v tmpfs | sed 's/ on//g'