简体   繁体   English

如何创建一个任务计划程序,使它每天每天运行我的.py文件?

[英]How to create a task scheduler which one run my .py file in every hour in every day?

I want to run my code with the task scheduler (so automatise it), which is a .py (Python 2.7) format. 我想使用任务调度程序(因此使其自动化)运行我的代码,该任务调度程序是.py(Python 2.7)格式。 How can I run this code in every hour? 我如何每小时运行一次此代码?

I know that how I have to open it (To open Task Scheduler, enter “sched” (without quotes) in the Start search box A three-pane console will open as shown in the figure above In the Actions pane on the right, click “Create Basic Task…”...), but I don't know what I have to set up to run this code in the correct way in every 1 hour in every day. 我知道如何打开它(要打开Task Scheduler,在“开始”搜索框中输入“ sched”(不带引号),将打开一个三窗格控制台,如上图所示。在右侧的“操作”窗格中,单击“确定”。 “创建基本任务...” ...),但我不知道要每天以正确的方式每1小时运行一次此代码需要设置什么。

try this, 尝试这个,

import schedule
import time
def task():
    print "Hello"
schedule.every(60).minutes.do(task)
while 1:
    schedule.run_pending()
    time.sleep(1)

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

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