# 自搭建了个人博客 有需要交流学习的可以访问 www.wpython.com
#!/usr/bin/env python import datetime,os,sys,shutil log_path = ‘/alidata/log/nginx/access/‘ log_file = ‘www.wpython.com.log‘ yesterday = (datetime.datetime.now() - datetime.timedelta(days = 1)) try: os.makedirs(log_path + yesterday.strftime(‘%Y‘) + os.sep + yesterday.strftime(‘%m‘)) except OSError,e: print print e sys.exit() shutil.move(log_path + log_file,log_path + yesterday.strftime(‘%Y‘) + os.sep + yesterday.strftime(‘%m‘) + os.sep + log_file + ‘_‘ + yesterday.strftime(‘%Y%m%d‘) + ‘.log‘) os.popen("sudo kill -USR1 `cat /alidata/server/nginx/logs/nginx.pid`")
nginx日志切割脚本,python实现,布布扣,bubuko.com
原文:http://xuqiangqiang.blog.51cto.com/8290140/1536530