如何安排不使用 Windows 任务计划程序运行 bat 文件?

2023-10-19Python开发问题
8

本文介绍了如何安排不使用 Windows 任务计划程序运行 bat 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个触发 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 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

在xarray中按单个维度的多个坐标分组
groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)...
2024-08-22 Python开发问题
15

Pandas中的GROUP BY AND SUM不丢失列
Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)...
2024-08-22 Python开发问题
17

GROUP BY+新列+基于条件的前一行抓取值
Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)...
2024-08-22 Python开发问题
18

PANDA中的Groupby算法和插值算法
Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)...
2024-08-22 Python开发问题
11

PANAS-基于列对行进行分组,并将NaN替换为非空值
Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)...
2024-08-22 Python开发问题
10

按10分钟间隔对 pandas 数据帧进行分组
Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)...
2024-08-22 Python开发问题
11