Cleanup Script für Debian

Nachdem ich ungern alles per hand mache, hab ich mir mal nen script geschrieben, dass die logfiles und den Ram-Cache leert. Dabei wird zuerst das logrotate ausgeführt und danach werden die .gz datein gelöscht.

 

#!/bin/bash
sync
echo 3 > /proc/sys/vm/drop_caches

cat /dev/null > /var/log/messages
cat /dev/null > /var/log/wtmp
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/apache2/error.log
cat /dev/null > /var/log/xferlog

logrotate -f /etc/logrotate.conf
find /var/log/ -name '*.gz' -exec rm "{}" \;
find /var/log/ -name '*.1' -exec rm "{}" \;
find /var/log/ -name '*.0' -exec rm "{}" \;

Published by

Kordian Bruck

I'm a TUM Computer Science Alumni. Pizza enthusiast. Passionate for SRE, beautiful Code and Club Mate. Currently working as an SRE at Google. Opinions and statements in this blog post are my own.

Leave a Reply