different backups for primary and secondary
[scripts/scripts.git] / logrotate.sh
1 #!/bin/sh
2
3 # rotate the messages file if >= 4M
4
5 dodel=0
6
7 logpaths="/var/log /var/opt/apache2/logs"
8 for i in `find $logpaths -size +3M`; do
9       rm -f ${i}.bz2
10       bzip2 $i
11       echo "rotated $i file, touching empty file."
12       [ ! -f $i ] && touch $i
13       dodel=1
14 done
15
16 if [ "$dodel" = "1" ] ; then
17   echo "rotated files, restarting some services ..."
18   /etc/init.d/sysklogd stop
19   /etc/init.d/apache stop
20   sleep 2
21   /etc/init.d/sysklogd start
22   /etc/init.d/apache start
23   echo "done."
24 fi