Last active
August 29, 2015 13:59
-
-
Save willgarcia/f8b5a62837aea8558cb6 to your computer and use it in GitHub Desktop.
centos-vm-clean
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
yum clean all | |
[ -f /root/.bash_history ] && rm -f /root/.bash_history | |
find /var/log -type f -name "*.log" | while read f; do echo -ne '' > $f; done; | |
dd if=/dev/zero of=/EMPTY bs=1M | |
rm -f /EMPTY | |
count=`df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}'`; | |
let count-- | |
dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count; | |
rm -f /tmp/whitespace; | |
count=`df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}'`; | |
let count-- | |
dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count; | |
rm -f /boot/whitespace; | |
swappart=`cat /proc/swaps | tail -n1 | awk -F ' ' '{print $1}'` | |
swapoff $swappart; | |
dd if=/dev/zero of=$swappart; | |
mkswap $swappart; | |
swapon $swappart; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment