-1
私のコードは、行ごとにファイルに書き込んでいません。それはループの最後のものだけを書いています。Pythonは行ごとに書いていません
コード -
for root, dirs, files in os.walk(lpath):
f = open("filelist.txt","w")
for name in fnmatch.filter(files, 'hdfs-audit.log.*'):
filename = os.path.join(root, name)
bname=ntpath.basename(filename)
if os.stat(filename).st_mtime < (now - (xdays * 86400)):
print(filename)
f.write(filename)
f.write("\n")
print("file_mtime:" + str(os.stat(filename).st_mtime))
print("now:" + str(now))
print("now - xdays * 86400:" + str(now - (xdays * 86400)))
f.close()
OutPut--
/var/log/hadoop/hdfs/hdfs-audit.log.2017-03-21
file_mtime:1490068800.0
now:1490592233.67
now - xdays * 86400:1490505833.67
/var/log/hadoop/hdfs/hdfs-audit.log.2017-03-20
file_mtime:1489982400.0
now:1490592233.67
now - xdays * 86400:1490505833.67
のみ
filelist.txtファイル内/var/log/hadoop/hdfs/hdfs-audit.log.2017-03-20
、それが含まれていないん
/var/log/hadoop/hdfs/hdfs-audit.log.2017-03-21
この理由は何でしょうか?
ありがとうございます – SLS