Browse Source

每月2日执行4点半

李莎 1 year ago
parent
commit
2ca0ff622c
2 changed files with 4 additions and 3 deletions
  1. 1 0
      Dockerfile
  2. 3 3
      main.py

+ 1 - 0
Dockerfile

@@ -4,6 +4,7 @@ FROM python:3.7.15-slim
 WORKDIR ./zjsys_equipment_quarter_history
 ADD . .
 
+RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
 RUN  pip install -r requirements.txt
 
 CMD ["python", "-u","./main.py"]

+ 3 - 3
main.py

@@ -32,12 +32,13 @@ end_date_month = (datetime.datetime.now() + dateutil.relativedelta.relativedelta
 # start_date_month = "20220903"
 # end_date_month = "20230201"
 def job():
-    if datetime.date.today().day != 1:
+    if datetime.date.today().day != 2:
         print("%s 等待4号执行程序"%datetime_now())
     else:
         # 连接mysql
         MysqlUtil = MysqlUtils(**mysql)
 
+        days = get_day_1(start_date_month, end_date_month)
         for date in days:
             print("%s 开始导入%s的数据"%(datetime_now(),date))
             MysqlUtil.update_two(REPLACE_EQUIP_SQL%(date),DELETE_EQUIP_SQL%(date))
@@ -48,8 +49,7 @@ def job():
         MysqlUtil.close()
 
 
-schedule.every().day.at("08:30").do(job)
+schedule.every().day.at("20:30").do(job)
 while True:
-    days = get_day_1(start_date_month, end_date_month)
     schedule.run_pending()
     time.sleep(30)