Skip to content

Instantly share code, notes, and snippets.

@willgarcia
Last active August 29, 2015 13:59
Show Gist options
  • Save willgarcia/f8b5a62837aea8558cb6 to your computer and use it in GitHub Desktop.
Save willgarcia/f8b5a62837aea8558cb6 to your computer and use it in GitHub Desktop.
centos-vm-clean
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