Script shows:
#!/usr/bin/env python
#coding: Utf-8
Import Time,sys,re,os,datetime
Delete_file_date = Datetime.datetime.now ()-Datetime.timedelta (days=8)
Delete_file_date=delete_file_date.strftime ('%y%m%d ')
FILE_DIRECTORY=SYS.ARGV[1]
FILE_NAME=SYS.ARGV[2]
result = Re.findall (' \w\s ', file_name)
Match_name= '. Join (Result)
File_list=os.listdir (File_directory)
For I in File_list:
If match_name in I:
Filemt=time.localtime (Os.stat (i). St_mtime)
Date=time.strftime ("%y%m%d", FILEMT)
If Delete_file_date > DATE:
Os.remove (i)
Executive presentation:
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9C/C5/wKiom1l1xNmy-XCaAAAh_xHCRII055.png "title=" QQ picture 20170724175810.png "alt=" Wkiom1l1xnmy-xcaaaah_xhcrii055.png "/>
This article is from "YHT's operations Notes" blog, please make sure to keep this source http://yht1990.blog.51cto.com/9014030/1950545
Python deletes the log that was matched eight days ago