任务调度程序认为 python 脚本仍在运行
我有一个 python 脚本,它依次执行其他 python 脚本。 我把它作为 WinXP 任务调度程序的一个任务。东西运行 - 命令提示符打开,火花四溅,魔法发生......最终任务完成,我得到了一个很好的结果 '打印脚本结束!!' 并返回提示。但任务计划程序认为任务仍在运行!这反过来又阻止它每天再次运行。
所以我尝试制作一个仅调用脚本的 BAT 文件:
script.py
echo pyfinished
令我惊讶的是,最后看不到“pyfinished”...
I have a python script which in turn executes other python scripts.
I put this as a task on WinXP task scheduler. the thing runs - command prompt is opened, sparks are flying, magic happens... eventually the task is completed, I get a nice
'print script ended!!'
and back to prompt. but Task Scheduler thinks the task is still running ! which in turn prevents it from running it again on daily basis.
so I tried making a BAT file which just calls the script:
script.py
echo pyfinished
to my surprise cannot see 'pyfinished' at the end ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有这个问题。为了确保脚本停止,我所做的是将任务配置为在 1 小时后停止(或者无论脚本需要花费多长时间)。这会终止任务,因此当任务计划再次到来时,启动就没有问题了。
至于为什么任务计划程序无法检测到脚本已完成,我不知道。这真是烦人。
I have this problem as well. What I did to make sure the script stops is configure the task to stop after 1 hour (or however long the script(s) should take). This kills the task and thus when the task schedule comes around again, it has no problem kicking off.
As for why Task Scheduler can't detect the script is finished, I have no idea. It's royally annoying.
带有 os.system('cmd /K script.py') 的行使进程保持活动状态,直到我手动终止它。
a line with
os.system('cmd /K script.py')
makes the process stay alive until I manually kill it.