![](/img/trans.png)
[英]How can I make a cron.yaml file to run python script every hour for google cloud app engine
[英]How can I make Python run at a specific time everyday and make it repeat every hour?
我做了一個 Python 腳本來提醒我每小時喝水。 我的代碼是:
import time
import plyer
from plyer import notification
if __name__ == "__main__":
while True:
plyer.notification.notify(
title="Go and Drink Water!",
message="You need to drink at least 3.5 litres of water Everyday. Being Dehydrated can decrease Brain Function and Energy levels.",
app_icon="C:\\Users\\(My username)\\(location of icon)",
timeout=10,
)
time.sleep(60 * 60)
我將 python 路徑和此腳本的路徑放在 a.bat 文件中,並使用任務計划程序使其每天早上 8:35 運行。 它確實在上午 8 點 35 分運行,但沒有重復。 誰能指出我做錯了什么或提出更好的方法?
使用 python APScheduler 模塊: https://apscheduler.readthedocs.io/en/stable/userguide.html#code-examples
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.