nginx 日志切割

#!/usr/bin/python
#-*-coding:UTF-8-*-
import time
import os
logdir='/data/log/nginx'
nginxpath='XX/logs/nginx.pid'
end_dir='/data/log/oldlog/'

str = time.strftime('%Y%m%d')
print str
tar_conn1 = "/bin/mv %s %s%s && /bin/mkdir -p %s && /bin/kill -USR1 `cat %s`" % (logdir,end_dir,str,logdir,nginxpath)
if os.system(tar_conn1) == 0:
     print '切割成功', str
else:
     print 'Error,操作失败'


 

posted @ 2016-07-19 16:10  小秒  阅读(201)  评论(0编辑  收藏  举报