968e77129b
* modules/openstack_project/files/log_archive_maintenance.sh: On occasion the compressor will be engaged on a file which is still being written to the log archive, resulting in a compressed but truncated copy along with the original it lacked the write lock to unlink. Then on a subsequent pass, this file will be skipped because the destination filename already exists. Instead, don't compress a file unless its last modified time is more than 10 minutes in the past. Change-Id: Ife874784babd41aa45b4183f4f0a5a5730cf5a23
21 lines
765 B
Bash
21 lines
765 B
Bash
#!/bin/sh
|
|
sleep $((RANDOM%600)) && \
|
|
flock -n /var/run/gziplogs.lock \
|
|
find /srv/static/logs/ -depth \
|
|
\( \
|
|
\( -type f -mmin +10 -not -name robots.txt \
|
|
-not -wholename /srv/static/logs/help/\* \
|
|
-not -name \*\[.-\]gz -not -name \*\[._-\]\[zZ\] \
|
|
\( -name \*.txt -or -name \*.html -or -name tmp\* \) \
|
|
-exec gzip \{\} \; \) \
|
|
-o \( -type f -mtime +183 -name \*.gz -execdir rm \{\} \; \) \
|
|
-o \( -type d -not -name lost+found -empty -mtime +1 \
|
|
-execdir rmdir {} \; \) \
|
|
\)
|
|
find /srv/static/docs-draft/ -depth \
|
|
\( \
|
|
\( -type f -mtime +30 -name \*.gz -execdir rm \{\} \; \) \
|
|
-o \( -type d -not -name lost+found -empty -mtime +1 \
|
|
-execdir rmdir {} \; \) \
|
|
\)
|