Browse Source

每月2日执行4点半

李莎 1 year ago
parent
commit
b8c5973325
1 changed files with 6 additions and 4 deletions
  1. 6 4
      main.py

+ 6 - 4
main.py

@@ -25,19 +25,21 @@ def datetime_now():
 
 mysql = {'database': 'sagacloud_review', 'host': '10.100.28.84', 'passwd': 'gWK5o9WmCBF5LiW', 'port': 9934, 'user': 'root'}
 
-start_date_month = (datetime.datetime.now() + dateutil.relativedelta.relativedelta(months=-2)).strftime("%Y%m")+"01"
-end_date_month = (datetime.datetime.now() + dateutil.relativedelta.relativedelta(months=-1)).strftime("%Y%m")+"01"
+
 # print(start_date_month,end_date_month)
 
 # start_date_month = "20220903"
 # end_date_month = "20230201"
 def job():
-    if datetime.date.today().day != 2:
+    if datetime.date.today().day != 3:
         print("%s 等待4号执行程序"%datetime_now())
     else:
         # 连接mysql
         MysqlUtil = MysqlUtils(**mysql)
-
+        start_date_month = (datetime.datetime.now() + dateutil.relativedelta.relativedelta(months=-2)).strftime(
+            "%Y%m") + "01"
+        end_date_month = (datetime.datetime.now() + dateutil.relativedelta.relativedelta(months=-1)).strftime(
+            "%Y%m") + "01"
         days = get_day_1(start_date_month, end_date_month)
         for date in days:
             print("%s 开始导入%s的数据"%(datetime_now(),date))