简体   繁体   English

每周自动运行python脚本(Windows)

[英]Run python script automatically every week (windows)

I wrote a little python Script that fetches data from some website using hard coded credentials ( i know its bad but not part of this question). 我编写了一个小python脚本,该脚本使用硬编码的凭据从某些网站获取数据(我知道它很糟糕,但不是这个问题的一部分)。

The website has new data every day and im gathering data from a whole week and parse it into a single .pdf. 该网站每天都有新数据,并且会收集整周的数据并将其解析为一个.pdf。

I've already adjusted the script to always generate a pdf off last week by default. 我已经调整了脚本,默认情况下总是在上周关闭pdf。 (no params needed) (无需参数)

Im kinda lazy and don't want to run the script every week by hand. 我有点懒,不想每周手动运行脚本。

So is it possible to run the script at certain times, for example every monday at 10am? 那么是否可以在某些时间(例如,每个星期一的上午10点)运行脚本?

Sure, just utilize Windows' task scheduler . 当然,只需利用Windows的任务计划程序即可 There you can create new tasks to your delight and let it run commands to whatever times or intervalls you want. 您可以在其中创建新任务,并根据需要随时随地运行命令。 The task schedulers' GUI should be self-explanatory, but to be concrete on your example: 任务计划程序的GUI应该是不言自明的,但是要具体说明您的示例:

  1. Configure the run time (weekly, monday, 10am) under triggers 触发器下配置运行时间 (每周,星期一,上午10点)
  2. Add a new action and give it your Python interpreter as the command and your script to be run as the argument 添加一个新操作 ,并将其作为命令的 Python解释器,并作为参数运行的脚本
  3. Configure the rest according to your needs 根据您的需求配置其余部分

In Linux this is Called Cron Job 在Linux中,这称为Cron Job

In windows we don't have cron Job command just like Linux does we want to set it 在Windows中,我们没有cron Job命令,就像Linux一样,我们想要设置它

Follow this link to set windows Cron Job 点击此链接设置Windows Cron Job

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

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