-
Notifications
You must be signed in to change notification settings - Fork 194
/
cron.py
25 lines (21 loc) · 791 Bytes
/
cron.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from datetime import datetime
import subprocess
from apscheduler.schedulers.blocking import BlockingScheduler
def update_data():
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
cmds = [
["git", "pull"],
["pipenv", "run", "python", "dataset.py"],
["pipenv", "run", "python", "data-join.py"],
["pipenv", "run", "python", "data-to-json.py"],
# ["pipenv", "run", "python", "data-to-xlsx.py"],
["git", "add", "."],
["git", "commit", "-m", f"""{now}自动更新"""],
["git", "push"]
]
for cmd in cmds:
print(" ".join(cmd))
print(subprocess.check_output(cmd).decode())
scheduler = BlockingScheduler(timezone="Asia/Shanghai")
scheduler.add_job(update_data, 'cron', minute="57")
scheduler.start()