erw23312 发表于 2015-6-16 08:40:11

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'


1307077801 发表于 2015-6-17 09:57:14

这个切割并没有重启生成,需要把cp 换成 mv吧

国安信仰 发表于 2015-6-17 16:50:53

学习了!!!!
页: [1]
查看完整版本: python的Nginx切割脚本