python的Nginx切割脚本
#!/usr/bin/env python#date:2015-06
#Author:ley
#Cur the nginx's access_log
#-*-coding:UTF-8-*-
import os,time
path=['/var/log/nginx/','/var/run/nginx/nginx.pid','access.log']
time=time.strftime('%Y-%m-%d')
command="cd %s && /bin/cp%s %s && /bin/kill -USR1 `cat %s`" % (path,path,time,path)
if os.system(command) == 0:
print 'Cur access_log is compelete!',time
else:
print 'Cur access_log is Failed'
这个切割并没有重启生成,需要把cp 换成 mv吧
学习了!!!!
页:
[1]