log_del.py 449 B

123456789101112131415
  1. # -*- coding:utf-8 -*-
  2. import os
  3. import datetime
  4. date = datetime.datetime.now()-datetime.timedelta(days=30)
  5. # print(date.strftime("%Y-%m-%d"))
  6. folder_path = "/home/user/EgoJC/EgoSystem/build/log/"
  7. if os.path.exists(folder_path):
  8. file_names = os.listdir(folder_path)
  9. for file_name in file_names:
  10. if date.strftime("%Y-%m-%d") > file_name[:10]:
  11. # print(folder_path+file_name)
  12. os.remove(folder_path+file_name)