5128ee3457
Add script and cron job to consolidate find through /srv/static/logs/ to gzip files and to search for .gz files over 183 days old and empty directories over a day old and remove them. Change-Id: I78f08852c8ee45fe8234d6b8ea0e25e199216cfd Reviewed-on: https://review.openstack.org/26049 Reviewed-by: Clark Boylan <clark.boylan@gmail.com> Reviewed-by: Monty Taylor <mordred@inaugust.com> Reviewed-by: James E. Blair <corvus@inaugust.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
12 lines
408 B
Bash
12 lines
408 B
Bash
#!/bin/sh
|
|
sleep $((RANDOM%600)) && \
|
|
flock -n /var/run/gziplogs.lock \
|
|
find /srv/static/logs/ -depth \
|
|
\( \
|
|
\( -type f -not -name robots.txt -not -name \*.gz \
|
|
\( -name \*.txt -or -name \*.html -or -name tmp\* \) \
|
|
-exec gzip \{\} \; \) \
|
|
-o \( -type f -mtime +183 -name \*.gz -execdir rm \{\} \; \) \
|
|
-o \( -type d -empty -mtime +1 -execdir rmdir {} \; \) \
|
|
\)
|