Browse Source

设备日志保留7天

locky 1 week ago
parent
commit
4b513b7ae9
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Controller/Cron/CronTaskController.py

+ 2 - 2
Controller/Cron/CronTaskController.py

@@ -451,9 +451,9 @@ class CronDelDataView(View):
         nowTime = int(time.time())
         try:
             cursor = connection.cursor()
-            month_ago_time = nowTime - 30 * 24 * 60 * 60  # 保留近30天的数据
+            expired_time = nowTime - 7 * 24 * 60 * 60  # 保留近7天的数据
 
-            sql = 'DELETE FROM `device_log` WHERE unix_timestamp(add_time)<{}'.format(month_ago_time)
+            sql = 'DELETE FROM `device_log` WHERE unix_timestamp(add_time)<{}'.format(expired_time)
             cursor.execute(sql)
             cursor.close()
             return response.json(0)