1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00
bitwarden-server/util/Nginx/logrotate.sh
Mart124 47bda1e6d0 Rotate nginx logs (#601)
* Rotate nginx logs

* Create logrotate.sh

* Update Dockerfile

* Update entrypoint.sh

* Update Dockerfile

* Update logrotate.sh

* No reason to disable logrotate

* Update logrotate.sh

* Update entrypoint.sh

* typo

* Avoid useless output

* Use gosu
2019-11-25 08:34:47 -05:00

16 lines
488 B
Bash

#!/bin/sh
while true
do
[ "$1" == "loop" ] && sleep $((24 * 3600 - (`date +%H` * 3600 + `date +%M` * 60 + `date +%S`)))
ts=$(date +%Y%m%d_%H%M%S)
mv /var/log/nginx/access.log /var/log/nginx/access.$ts.log
mv /var/log/nginx/error.log /var/log/nginx/error.$ts.log
kill -USR1 `cat /var/run/nginx/nginx.pid`
sleep 1
gzip /var/log/nginx/access.$ts.log
gzip /var/log/nginx/error.$ts.log
find /var/log/nginx/ -name "*.gz" -mtime +32 -delete
[ "$1" != "loop" ] && break
done