[英]exe file created using pyinstaller in windows 10 does not run in windows 8
[英]Schedule to run .exe file created using pyinstaller at specific time and day.(not task scheduler)
我從事過 python 項目,並使用 pyinstaller 創建了一個 .exe 文件。 現在我有了我需要在公司的每台機器(台式機/筆記本電腦)上運行的可執行文件。 我正在尋找一種調度解決方案,我可以在其中安排 .exe 文件在每 2 小時后運行一次,並且僅在特定日期運行。 有人可以指導我使用調度工具或任何我可以安排在每台機器上運行可執行文件的方式。
需要考慮的事情:不需要或說不需要在所有機器上安裝軟件的解決方案。 我使用 pyinstaller 創建.exe 文件的原因是它不需要在所有機器上安裝 python。
我會做類似上面報告的代碼的事情。 請注意,在示例中,我設置了睡眠一秒,這意味着 function 每秒檢查一次是否是執行作業的正確時間。 如果您的執行時間精度以分鍾為單位,您可以睡眠 60 英寸。
import time
# here the time and date when you want to execute your job
datetime_of_exe = 'Mon Dec 14 12:00:00 2020'
# this is the job I want to do
def job():
print('I am working now!')
# this function to check if it is the right datetime to execute the job
def timeToExecute(datetime):
if time.ctime() == datetime:
return True
else:
return False
# this loop works 24h and exits after the job is done
while True:
if timeToExecute(datetime_of_exe):
job()
exit()
time.sleep(1)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.