问题描述
我有一个触发 Python 脚本的批处理 (*.bat) 文件,该脚本需要大约 25 分钟才能交互完成(通过手动命令提示符).这个批处理文件需要每天早上运行.
I have a batch (*.bat) file that triggers a Python script and this script takes about 25 minutes to complete interactivly (through command prompt manuallly). This batch file needs to run in the morning on a daily basis.
当我尝试在 Windows 任务计划程序上将其设置为计划任务并在那里运行时,它所花费的时间几乎是交互时间的两倍.即使我在 xml 中将优先级设置从默认的 7 设置为 4(更高优先级),也没有任何区别.更改优先级设置仅适用于 I/O 优先级,但不适用于内存优先级,内存优先级仍保持在 4(交互式运行的下一级为 5).内存优先级在支持长流程方面发挥着重要作用.
When I tried to set it as a Scheduled Task on Windows Task Scheduler and ran it there, it took nearly double the time than it did interactively. Even if I set the Priority settings from the default 7 to 4 (higher priority) in the xml, it didn't make any differnce. Changing the Priority settings only works for I/O Priority but does not work for Memory Priority, which still remains at 4 (1 level down the interactive run which is 5). Memory Priority plays an important role in supporting a long process.
我想知道是否有办法将 bat 文件作为计划任务触发,但不使用任务计划程序、任务计划程序的替代程序或脚本?
I am wondering if there is a way to trigger the bat file as a scheduled task but not using Task Scheduler, alternative program to Task Scheduler or scripts?
推荐答案
由于上面没有退出策略并且延迟至少25分钟,这个批处理文件代码可能更适合你的需要,在你的登录批处理或其他触发器...
As the above has no exit strategy and is delayed for at least 25 minutes, this batch file code may be better suited to your need, drop a reference into your login batch or other trigger...
@echo off
:loop
set timeHrs=%time:~0,2%
set timeMin=%time:~3,2%
set timeSec=%time:~6,2%
if "%timeHrs%" geq 6 if "%timeHrs%" leq 9 (
[command to trigger Python script]
exit /b 0
)
timeout /t 1500
goto loop
这篇关于如何安排不使用 Windows 任务计划程序运行 bat 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!