Created
June 16, 2015 09:04
-
-
Save chluehr/20b0e122f4e213844c6c to your computer and use it in GitHub Desktop.
Simple Script to delete all old kernels except the last recent 2 (after auto-updates) - use with caution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OLD=$(ls -tr /boot/vmlinuz-* | head -n -3 | cut -d- -f2- | | |
awk '{print "linux-image-" $0 " linux-headers-" $0}' ) | |
echo "OLD:" | |
echo "$OLD" | |
echo | |
echo -n "CURRENT: " | |
uname -r | |
echo "continue?" | |
read DUMMY | |
if [ -n "$OLD" ]; then | |
apt-get -qy remove --purge $OLD | |
fi | |
apt-get -qy autoremove --purge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment