Skip to content

Instantly share code, notes, and snippets.

@GreepTheSheep
Created March 6, 2023 14:44
Show Gist options
  • Save GreepTheSheep/eda27251ece1ca2966e59d5707650dd6 to your computer and use it in GitHub Desktop.
Save GreepTheSheep/eda27251ece1ca2966e59d5707650dd6 to your computer and use it in GitHub Desktop.
Script to cleanup Debian server
#!/bin/bash
# Delete old log files
sudo find /var/log -type f -name "*.gz" -exec rm -f {};
sudo find /var/log -type f -name "*.log.*" -exec rm -f {} \;
sudo find /var/log -type f -name "*.1" -exec rm -f {} \;
# Delete temporary files
sudo rm -rf /tmp/*
# Delete unused dependencies
sudo apt-get autopurge -y > /dev/null
# Delete cache files
sudo apt-get clean -y > /dev/null
# Delete docker log files
sudo find /var/lib/docker/containers/ -type f -name "*-json.log" -exec rm -f {} \;
# Delete old unused container, images and volumes on docker
sudo docker container prune -f
sudo docker image prune -a -f
sudo docker system prune -a -f --volumes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment