任务调度程序认为 python 脚本仍在运行

发布于 2024-10-28 04:29:30 字数 283 浏览 5 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-11-04 04:29:30

我也有这个问题。为了确保脚本停止,我所做的是将任务配置为在 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.

や莫失莫忘 2024-11-04 04:29:30

带有 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文