简体   繁体   English

如何在Windows 10最佳实践中不断运行python脚本?

[英]How to run a python script constantly on Windows 10 best practice?

I'm trying to run a script on windows 10 machine that I set a server in my LAN. 我试图在Windows 10计算机上运行脚本,该计算机在LAN中设置了服务器。 I would like for the script to restart 30 seconds after it finished, forever. 我希望脚本完成后30秒钟永远重新启动。 Is there any better way then putting it in an infinite while loop? 还有什么更好的方法可以将其放入无限while循环中吗?

Here is my code: 这是我的代码:

import Time 
while True:
     print("Here does all the things it's supposed to")
     # Does something
     time.wait(30)

While this works, I'm worried that it will affect performance and maybe memory of of the server or slowing it down in time. 虽然这样做有效,但我担心它会影响服务器的性能和内存,或降低其速度。

Is there any better way to run a code forever in a loop in windows, perhaps with some command for terminal or any other option better then mine? 有没有更好的方法可以在Windows的循环中永久运行代码,也许可以使用一些用于终端的命令或比我更好的任何其他选项? Kindly note the machine is a windows 10, 64 Bit arch, not a linux machine. 请注意,该机器是Windows 10、64位Arch,而不是Linux机器。

You can look up a term more famously known as a "chron job" Heres an article I found out which can help: https://www.technipages.com/scheduled-task-windows 您可以查找一个较有名的术语“计时作业”,以下是我发现可以提供帮助的文章: https ://www.technipages.com/scheduled-task-windows

using "chron" you can schedule when to run a script at exact date and time. 使用“ chron”,您可以计划何时在确切的日期和时间运行脚本。 Or choose how to run code in infinite loop. 或选择如何在无限循环中运行代码。 You can also decide when to stop the script 您还可以决定何时停止脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM