[英]Reloading a python script using a batch file every hour
Good day to all!大家好! From time to time the script turns off.
脚本不时关闭。 Drops.
滴。 I solved this problem with the following batch file:
我用以下批处理文件解决了这个问题:
@echo off
:start
python script.py %*
goto start
Please tell me how to reload the script once an hour?请告诉我如何每小时重新加载一次脚本? I have tried given commands:
我试过给定的命令:
@echo off
:start
python script.py %*
timeout /t 3600
taskkill /im cmd.exe /f ; or python.exe ; or py.exe
goto start
Unfortunately it does not come out :(不幸的是它没有出来:(
Try:尝试:
@echo off
:start
cls
python script.py %*
timeout /t 3600 /nobreak
tasklist | find /i "python.exe" >NUL && taskkill /f /im "python.exe" || taskkill /f /im "py.exe"
goto start
The script will check if "python.exe" is running (in this case it will be killed), else the script will kill "py.exe".脚本将检查“python.exe”是否正在运行(在这种情况下它将被杀死),否则脚本将杀死“py.exe”。 The /nobreak attribute makes sure that the timeout will continue running even if you press a key and the /t attribute on taskkill kills the process and all of his childs
/nobreak 属性确保即使您按下某个键超时也会继续运行,并且 taskkill 上的 /t 属性会终止进程及其所有子进程
Sorry for bad english抱歉英语不好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.