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

时间:2023-01-02 01:09:17

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. (no params needed)

我已经调整了脚本,以便在上周默认生成一个pdf。 (不需要参数)

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点?

2 个解决方案

#1


1  

Sure, just utilize Windows' task scheduler. 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:

当然,只需使用Windows的任务调度程序。在那里,您可以创建新的任务,让它快乐,并让它运行命令到任何时间或你想要的intervalls。任务调度程序的GUI应该是不言自明的,但要在您的示例中具体说明:

  1. Configure the run time (weekly, monday, 10am) under triggers
  2. 在触发器下配置运行时间(每周,星期一,上午10点)

  3. Add a new action and give it your Python interpreter as the command and your script to be run as the argument
  4. 添加一个新操作,并将其作为命令提供Python解释器,并将脚本作为参数运行

  5. Configure the rest according to your needs
  6. 根据您的需要配置其余部分

#2


-1  

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中,我们没有像Linux那样的cron Job命令我们想要设置它

Follow this link to set windows Cron Job

点击此链接设置Windows Cron Job

#1


1  

Sure, just utilize Windows' task scheduler. 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:

当然,只需使用Windows的任务调度程序。在那里,您可以创建新的任务,让它快乐,并让它运行命令到任何时间或你想要的intervalls。任务调度程序的GUI应该是不言自明的,但要在您的示例中具体说明:

  1. Configure the run time (weekly, monday, 10am) under triggers
  2. 在触发器下配置运行时间(每周,星期一,上午10点)

  3. Add a new action and give it your Python interpreter as the command and your script to be run as the argument
  4. 添加一个新操作,并将其作为命令提供Python解释器,并将脚本作为参数运行

  5. Configure the rest according to your needs
  6. 根据您的需要配置其余部分

#2


-1  

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中,我们没有像Linux那样的cron Job命令我们想要设置它

Follow this link to set windows Cron Job

点击此链接设置Windows Cron Job