File tree Expand file tree Collapse file tree
ansible/roles/loggly/files Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44# This is to be run only for legacy logs in /var/log, not application logs in /var/log/runnable
55#
66
7+ # we only want this run as root
78if [ " root" != ` whoami` ] ; then
89 echo " It don't mean a thing if it ain't got that swing."
910 exit 127
1011fi
1112
12- LOGDIR=/var/log
13- ARCHDIR=/docker/archive
14- DATE=` date +%Y%m%d%H%m`
13+ # legacy log path
14+ logdir=/var/log
15+ # store log archives here, purge manually
16+ archdir=/docker/archive
17+ datetime=` date +%Y%m%d%H%m`
1518
16- # these haven't been modified in > 24 hours, so "doing it live" should be OK:
19+ # these logfiles haven't been modified in > 24 hours, so moving them without cleanup up filehandles first should be OK:
1720echo " Compressing logs > 24h"
18- find ${LOGDIR } -maxdepth 2 -type f -mmin +1440 -name ' *.log' -exec bzip2 -9 {} \; -print
21+ find ${logdir } -maxdepth 2 -type f -mmin +1440 -name ' *.log' -exec bzip2 -9 {} \; -print
1922echo " Restarting rsyslogd"
23+ # but we do need to clean the filehandles after, just in case
2024service rsyslog restart
2125
2226# archive anything > 1wk
2327echo " Archiving logs > 1wk"
24- mkdir -p ${ARCHDIR } 2>&1
25- find ${LOGDIR } -maxdepth 2 -type f -mtime +6 -name ' *z' | xargs tar jcvpf ${ARCHDIR } /log-archive-${DATE } .tbz
28+ mkdir -p ${archdir } 2>&1
29+ find ${logdir } -maxdepth 2 -type f -mtime +6 -name ' *z' | xargs tar jcvpf ${archdir } /log-archive-${datetime } .tbz
2630echo " Purging logs > 1wk"
27- find ${LOGDIR } -maxdepth 2 -type f -mtime +6 -exec rm -f {} \; -print
31+ find ${logdir } -maxdepth 2 -type f -mtime +6 -exec rm -f {} \; -print
Original file line number Diff line number Diff line change 55# Runs from crontab.
66#
77
8- LOGDIR =${1}
8+ logdir =${1}
99
1010# We can compress anything older than 6 hours
11- find ${LOGDIR } -mindepth 2 -type f -mmin +360 -name ' *.log' -exec bzip2 -9 {} \;
11+ find ${logdir } -mindepth 2 -type f -mmin +360 -name ' *.log' -exec bzip2 -9 {} \;
1212
13- # purge anything > 1wk
14- find ${LOGDIR } -maxdepth 2 -type f -mtime +6 -exec rm -f {} \;
13+ # We automatically purge anything > 1wk
14+ find ${logdir } -maxdepth 2 -type f -mtime +7 -exec rm -f {} \;
You can’t perform that action at this time.
0 commit comments