计划的任务未在Windows中触发
我想每天5分钟每5分钟运行以下Python脚本:
c:\ users \ ****** \ desktop \ task \ task.py.py
i创建以下任务:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-04-18T16:12:35.5603012</Date>
<Author>DESKTOP-*****\*****</Author>
<URI>\tast test</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<Repetition>
<Interval>PT5M</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2022-04-18T00:00:00</StartBoundary>
<EndBoundary>2023-04-20T16:06:26</EndBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>******</UserId>
<LogonType>S4U</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<DeleteExpiredTaskAfter>P30D</DeleteExpiredTaskAfter>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT1M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\*****\AppData\Local\Programs\Python\Python39\python.exe</Command>
<Arguments>task.py</Arguments>
<WorkingDirectory>C:\Users\****\Desktop\task</WorkingDirectory>
</Exec>
</Actions>
</Task>
python脚本不会每5分钟执行一次,但是下一个运行时会更改,最后一个运行时间仍然显示为< a href =“ https://i.sstatic.net/tyl1f.png” rel =“ nofollow noreferrer”>
I would like to run the below python script every 5 mins on the daily basis:
C:\Users\******\Desktop\task\task.py
I created the below task:
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2022-04-18T16:12:35.5603012</Date>
<Author>DESKTOP-*****\*****</Author>
<URI>\tast test</URI>
</RegistrationInfo>
<Triggers>
<CalendarTrigger>
<Repetition>
<Interval>PT5M</Interval>
<StopAtDurationEnd>false</StopAtDurationEnd>
</Repetition>
<StartBoundary>2022-04-18T00:00:00</StartBoundary>
<EndBoundary>2023-04-20T16:06:26</EndBoundary>
<Enabled>true</Enabled>
<ScheduleByDay>
<DaysInterval>1</DaysInterval>
</ScheduleByDay>
</CalendarTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>******</UserId>
<LogonType>S4U</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>true</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
<DeleteExpiredTaskAfter>P30D</DeleteExpiredTaskAfter>
<Priority>7</Priority>
<RestartOnFailure>
<Interval>PT1M</Interval>
<Count>3</Count>
</RestartOnFailure>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\*****\AppData\Local\Programs\Python\Python39\python.exe</Command>
<Arguments>task.py</Arguments>
<WorkingDirectory>C:\Users\****\Desktop\task</WorkingDirectory>
</Exec>
</Actions>
</Task>
The python script is not executed every 5 mins, but the Next runtime gets changed and the last run time still shows as
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如@daemon的注释中所述,在设置计划的任务操作时,命令字段应包含可执行的路径(例如
c:\ users \ ******* \ appdata \ appdata \ local \ local \ program \ python \ python39 \ python.exe
),参数字段应包含要运行的文件的完整路径,在这种情况下,这可能是c:\ users \ users \ **** \ desktop \ desktop \任务\ task.py
。所以我希望动作部分看起来像
As stated in the comment from @Daemon, when setting up a scheduled task action, the command field should contain the path to the executable (e.g
C:\Users\*****\AppData\Local\Programs\Python\Python39\python.exe
) and the arguments field should contain the full path to the file you want to run, which in this case should presumably beC:\Users\****\Desktop\task\task.py
.So I would expect the action section to look like