mein |
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#!/bin/bash
#
# written by KLS 03-31-2007 (based on Knoppix CLEAN.sh)
#
# This script cleans up /var
#
# Tested on Ubuntu 6.10 - 2.6.20-rt3
#
# Revison PA1 03-31-2007
#
#-----------------------------------------------------------------------
# Check root
#-----------------------------------------------------------------------
checkroot () {
if [ "$UID" -ne 0 ]
then
echo "Must be root to run this script..."
exit $E_NOTROOT
fi
}
#-----------------------------------------------------------------------
# Setenv and stop logging
#-----------------------------------------------------------------------
stopproc () {
umask 022
/etc/init.d/apmd stop > /dev/null 2>&1
/etc/init.d/networking stop > /dev/null 2>&1
/etc/init.d/cron stop > /dev/null 2>&1
/etc/init.d/klogd stop > /dev/null 2>&1
/etc/init.d/sysklogd stop > /dev/null 2>&1
/etc/init.d/acpid stop > /dev/null 2>&1
}
#-----------------------------------------------------------------------
# restart logging
#-----------------------------------------------------------------------
restartproc () {
/etc/init.d/apmd start > /dev/null 2>&1
/etc/init.d/networking start > /dev/null 2>&1
/etc/init.d/cron start > /dev/null 2>&1
/etc/init.d/klogd start > /dev/null 2>&1
/etc/init.d/sysklogd start > /dev/null 2>&1
/etc/init.d/acpid start > /dev/null 2>&1
}
#-----------------------------------------------------------------------
# remove only "temporary" or saved files in the given directories
#-----------------------------------------------------------------------
nuke(){
for i in `find $@ -name \*.gz -o -name \*.bz2 -o -name \*.0 -o -name \*.0.log -o -name browse.dat -o -name \*.\*pk 2>/dev/null`; do
rm -f "$i"
done
}
#-----------------------------------------------------------------------
# set all files in the given directories to a length of zero
#-----------------------------------------------------------------------
zero(){
for i in `find $@ -type f -size +0 -not -name \*.ini 2>/dev/null`; do
cat /dev/null>"$i"
done
}
#-----------------------------------------------------------------------
# main
#-----------------------------------------------------------------------
checkroot
stopproc
rm -rf /tmp/* /var/tmp/* /var/tmp/.??* /var/backups/* \
/var/run/screen/* /var/spool/squid/*
nuke /var/log /var/cache
zero /var/local /var/log /var/spool /var/mail \
/var/cache/man /var/lib/wine \
/var/lib/nfs /var/lib/xkb
apt-get clean
restartproc
echo "Done..."
|

Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von »kls« (1. April 2007, 18:35)
Benutzerinformationen überspringen
Ubuntu: 12.04
Kernel: 3.2.0-24-generic
Desktop: KDE
Architektur: 64-bit
Burning Board, entwickelt von WoltLab GmbH.
UbuntuFreunde von Easyy-S und basslord seit 06.12.06
Ubuntufreunde.de runs on ubuntu 10.04





