python删除nginx反响代理缓存代码,pythonnginx,#!/usr/bin/e


#!/usr/bin/env python'''Clear nginx a url cache'''import ostry:    from hashlib import md5except:    from md5 import md5url=raw_input('Please enter url : ')isClr=raw_input("You sure you want to clear  '%s'   cache ? (y/n)   " % url)if isClr=='y' or isClr=='Y' :    m=md5()    m.update("%s" % url)    md5url=m.hexdigest()    md5urllen=len(md5url)    dir1=md5url[md5urllen-1:]    dir2=md5url[md5urllen-3:md5urllen-1]    dirPath=("/usr/local/nginx/proxy_cache/%s/%s/%s" % (dir1, dir2, md5url))    isDel=raw_input("Will be deleted : %s (y/n)   " % dirPath)    if isDel=='y' or isDel=='Y' :        if(os.path.exists(dirPath)) :            os.remove(dirPath)            print 'delete success'        else :            print 'file not find'

评论关闭