1
0

clean.sh 1.0 KB

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. #########################################################################
  3. # Script for cleaning logs #
  4. # Created by PM-DoIT #
  5. # ver 0.5 #
  6. #########################################################################
  7. clear
  8. echo -e "- [\e[1;33mCleaning\e[0m] logs and history"
  9. HIS=$(find /home/ -name .bash_history)
  10. for h in $HIS; do rm -rf $h; done
  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. history -c
  16. echo -e "- [\e[1;33mCleaning\e[0m] APT archives"
  17. apt autoclean > /dev/null 2>&1
  18. apt clean > /dev/null 2>&1
  19. apt autoremove -y > /dev/null 2>&1
  20. pip cache purge > /dev/null 2>&1
  21. echo -e "- [\e[1;33mCleaning\e[0m] Journal"
  22. journalctl --vacuum-size=100M > /dev/null 2>&1
  23. echo -e "- [\e[1;32mActual size\e[0m] of partition"
  24. df -h | grep -v tmpfs | sed 's/ on//g'