aktueller stand
This commit is contained in:
commit
2c1850e454
16
lmtab.example
Normal file
16
lmtab.example
Normal file
|
@ -0,0 +1,16 @@
|
|||
#
|
||||
# Diese Datei sollte ~/.lmtab heiszen.
|
||||
#
|
||||
|
||||
/opt/jbossmsg/jboss/server/default_4/log *.log 30
|
||||
|
||||
# Vorsicht:
|
||||
# Keine Angabe der Zeit, wann die Datei entfernt werden soll,
|
||||
# bedeutet, dass sie nach 60 Tagen entfernt wird.
|
||||
# Wenn die Datei nie entfernt werden soll, 0 angeben.
|
||||
|
||||
#/var/opt/mmp/log/tomcat * 0
|
||||
|
||||
# Mehrere Dateipatterns sind ebenso moeglich:
|
||||
|
||||
#/var/opt/mmp/log/mmp *.log.*/*.log
|
48
logarchiver
Executable file
48
logarchiver
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
|
||||
e='*.log'
|
||||
i=
|
||||
n=
|
||||
p=gzip
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
`basename "$0"` -h | [-i|-n] [-e EXP] DIR [DIR [...]]
|
||||
Dursucht DIR und dessen Unterverzeichnisse nach Dateien und verschiebt alle,
|
||||
die auf den Ausdruck EXP passen nach DIR/archive.
|
||||
-e EXP Ausdruck, der gefunden werden soll (std: "$e")
|
||||
-n Trockenlauf: Zeigt nur die Dateinamen an.
|
||||
-i Fragt nach (siehe mv)
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
[ 0 -lt $# ] || help
|
||||
x=`getopt hnie: "$@"` || exit 1
|
||||
eval set -- $x
|
||||
|
||||
while [ 0 -lt $# ]
|
||||
do
|
||||
o=$1
|
||||
shift
|
||||
case "$o" in
|
||||
--) break ;;
|
||||
-h) help ;;
|
||||
-e) e=$1 ; shift ;;
|
||||
-n) n=echo ;;
|
||||
-i) i=-i ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ 0 -lt $# ] || help
|
||||
|
||||
for d
|
||||
do
|
||||
find "$d" -name archive -prune -o -type f \( -name "${e}" \) -exec sh -c '
|
||||
if [ X = "X`fuser "$1" 2>/dev/null`" ]
|
||||
then
|
||||
a="`dirname "$1"`/archive"
|
||||
'"$n"' mkdir -p -- "$a"
|
||||
'"$n"' mv '$i' -- "$1" "$a"
|
||||
fi ' -- '{}' \;
|
||||
done
|
41
logcleaner
Executable file
41
logcleaner
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
a=60
|
||||
n=
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
Usage: `basename "$0"` -h | [-i|-n] [-a AGE] DIR [DIR [...]]
|
||||
Findet alle Dateien in DIR/archive, die zu alt sind und loescht sie.
|
||||
-a Alter der Datei in Tagen (std: $a)
|
||||
-i Fragt vorher nach (siehe rm)
|
||||
-n Trockenlauf
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
[ 0 -lt $# ] || help
|
||||
x=`getopt hina: "$@"` || exit 1
|
||||
eval set -- $x
|
||||
|
||||
while [ 0 -lt $# ]
|
||||
do
|
||||
o=$1
|
||||
shift
|
||||
case "$o" in
|
||||
--) break ;;
|
||||
-h) help ;;
|
||||
-a) a=$1 ; shift ;;
|
||||
-i) i=-i ;;
|
||||
-n) n=echo ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ 0 -lt $# ] || help
|
||||
[ X = X"$a" ] || a="-mtime +$a"
|
||||
|
||||
for d
|
||||
do
|
||||
find "$d" -name archive -type d -exec sh -c '
|
||||
find "$1" -type f '"$a"' -exec '"$n"' rm '"$i"' -- "{}" \;' -- '{}' \;
|
||||
done
|
38
logcompressor
Executable file
38
logcompressor
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
Usage: `basename "$0"` -h | [-n] DIR [DIR [...]]
|
||||
Komprimiert alle Dateien in DIR/archive.
|
||||
-n Trockenlauf
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
[ 0 -lt $# ] || help
|
||||
x=`getopt he:ngblc: "$@"` || exit 1
|
||||
eval set -- $x
|
||||
p=gzip
|
||||
|
||||
while [ 0 -lt $# ]
|
||||
do
|
||||
o=$1
|
||||
shift
|
||||
case "$o" in
|
||||
--) break ;;
|
||||
-h) help ;;
|
||||
-n) n=echo ;;
|
||||
-g) p=gzip ;;
|
||||
-b) p=bzip2 ;;
|
||||
-l) p=lzma ;;
|
||||
-c) p="$1" ; shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ 0 -lt $# ] || help
|
||||
|
||||
for d
|
||||
do
|
||||
find "$d" -name archive -type d -exec sh -c '
|
||||
find "$1" -type f ! -name "*.bz2" ! -name "*.gz" ! -name "*.lzma" -exec '"$n"' '"$p"' -- "{}" \;' -- '{}' \;
|
||||
done
|
63
logmanager
Executable file
63
logmanager
Executable file
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
|
||||
archiver=`dirname "$0"`/logarchiver
|
||||
rotator=`dirname "$0"`/logrotator
|
||||
compressor=`dirname "$0"`/logcompressor
|
||||
cleaner=`dirname "$0"`/logcleaner
|
||||
cmd=
|
||||
|
||||
help() {
|
||||
cat <<EOF
|
||||
`basename "$0"` -h | [-a EXE] [-z EXE] [-C EXE] -c CONF
|
||||
-c CONF Konfigurationsdatei
|
||||
-a EXE Archiver (std: ./logarchiver)
|
||||
-z EXE Compressor (std: ./logcompressor)
|
||||
-C EXE Cleaner (std: ./logcleaner)
|
||||
-n Gibt die Befehle aus, die Ausgefuehrt werden wuerden
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
|
||||
x=`getopt hc:a:r:z:C:n "$@"` || exit 1
|
||||
eval set -- $x
|
||||
|
||||
while [ 0 -lt $# ]
|
||||
do
|
||||
o=$1
|
||||
shift
|
||||
case "$o" in
|
||||
--) break ;;
|
||||
-h) help ;;
|
||||
-c) c=$1 ; shift ;;
|
||||
-a) archiver="$1" ; shift ;;
|
||||
-r) rotator="$1" ; shift ;;
|
||||
-z) compressor="$1" ; shift ;;
|
||||
-C) cleaner="$1" ; shift ;;
|
||||
-n) cmd=echo ;;
|
||||
esac
|
||||
done
|
||||
|
||||
for n in $c ./lmtab ~/.lmtab /etc/lmtab
|
||||
do
|
||||
if [ -f "$n" ]
|
||||
then
|
||||
c=$n
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Format: Verzeichnis [Ausdruck[,Ausdruck[,...]] [Aufbewahrungszeit]]
|
||||
# Verzeichnisse duerfen nur einmalig Vorkommen
|
||||
sed -ne 's/#.*//;/\//p' "$c" | while read dir exp age opts
|
||||
do
|
||||
[ X = "X$age" ] || age="-a$age"
|
||||
while [ ! "X." = "X${exp}" ]
|
||||
do
|
||||
e="`basename "${exp}"`"
|
||||
exp="`dirname "${exp}"`"
|
||||
[ X = "X$e" ] || e="-e$e"
|
||||
$cmd $archiver "$e" "$dir"
|
||||
$cmd $compressor "$dir"
|
||||
[ 0 = "$age" ] || $cmd $cleaner "$age" "$dir"
|
||||
done
|
||||
done
|
Loading…
Reference in a new issue