Skip to content

Instantly share code, notes, and snippets.

@robflaherty
Created September 6, 2010 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robflaherty/567525 to your computer and use it in GitHub Desktop.
Save robflaherty/567525 to your computer and use it in GitHub Desktop.
Script for rotating nginx logs
#!/usr/bin/evn python2.6
# Shell script for rotating/archiving nginx logs
import os
from datetime import datetime
cwd = os.getcwd()
date = datetime.now().strftime("%Y-%m-%d")
cmd = """\
mv %s/access.log %s/archive/access.%s.log
kill -USR1 `cat %s/nginx.pid`
sleep 1
gzip %s/archive/access.%s.log
""" % (cwd, cwd, date, cwd, cwd, date)
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment