Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mattantonelli/da586f21a69f9097f2e7e79a4aabcb0e to your computer and use it in GitHub Desktop.

Select an option

Save mattantonelli/da586f21a69f9097f2e7e79a4aabcb0e to your computer and use it in GitHub Desktop.
Bootleg log rotation for NGINX. Retains at least one month of logs before they are overwritten.
cd /opt/nginx/logs
mv access_old.log.gz access_older.log.gz
mv access.log access_old.log
kill -USR1 `cat /var/run/nginx.pid`
sleep 1
gzip access_old.log
0 0 1 * * root /opt/nginx/logs/bootleg_nginx_monthly_log_rotation.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment