简体   繁体   English

如何编写Windows服务以安排在特定时间运行python脚本

[英]How to write windows service to schedule run python script in particular time

I want to run a python script at a particular time. 我想在特定时间运行python脚本。 say Everyday 10am or every 2 hours . Everyday 10am or every 2 hours How can I achieve that? 我该如何实现? I have read these questions- Q1 Q2 我已经阅读了这些问题-Q1 Q2

You don't need a service to schedule a Python script. 您不需要服务即可安排Python脚本。 Just use Windows Task Scheduler to run it. 只需使用Windows Task Scheduler即可运行它。 When I do this I usually wrap the invocation of Python in a batch file, so the scheduler runs mytask.cmd but you can also schedule a complete command line invocation of the interpreter, for example: c:\\python36\\python.exe mytask.py . 当我这样做时,我通常将对Python的调用包装在一个批处理文件中,以便调度程序运行mytask.cmd但您也可以调度对解释程序的完整命令行调用,例如: c:\\python36\\python.exe mytask.py

Task Scheduler is in the Control Panel. 任务计划程序在控制面板中。 Open Control Panel, and in the top right hand corner ("Search Control Panel") type Schedule . 打开控制面板,然后在右上角(“搜索控制面板”)中输入Schedule One of the options you will get is Administrative Tools | 您将获得的选项之一是“管理工具”。 Schedule tasks. 安排任务。

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

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