blob: 9023a82e346816f1977fef279a2d26e0b517e9b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
#!/bin/bash
. /etc/profile
YEAR=`date +%Y`
LASTYEAR=$(($YEAR - 1))
for DATE in $YEAR $LASTYEAR
do
echo "Compressing log files"
find /var/log/$DATE* -mtime +1 -exec gzip -9 {} \;
echo "Deleting old log files"
find /var/log/$DATE* -mtime +12 -exec rm -rf {} \;
echo "Deleting empty directories"
find /var/log/$DATE* -depth -type d -empty -exec rm -rf {} \;
done
|