windows 10 How to set up a scheduled task to automatically execute python script?

I used pythonto write some scripts, there are some 爬虫scripts, such as crawling known hot issue almost certain topic, there are some regular 统计分析script, output statistics in the document. Before I always manually execute these scripts, and now I want to how these scripts can be automatically timed execution. So, windows 10 operating system how to automatically execute a python script?

My device is windows 10 operating system, comes with the "Scheduled Tasks" to meet my needs, specific steps are summarized as follows.

Step 1: Open the "Computer Management" interface

Click the lower-left corner of the icon windows, or windows keys of the keyboard.

image

In the pop-up interface, mouse over "This Computer" right click and select "More" - 'Management', you can click into the "Computer Management" screen.

image

Step 2: Start "Create Basic Task"

On the open "Computer Management" menu, then click the "System Management" - "Task Scheduler" and then select the far right "Create Basic Task" to start creating a scheduled task.

image

Step 3: Enter basic properties of the scheduled task

Property of the scheduled task is divided into multiple steps, in accordance with the operating instructions step by step to come. Even the beginning of a mistake, then you can modify or improve. So do not be nervous. The first time, may in turn try the following screenshot:

- Enter a name and description of the task.

Note: This is for myself to see yo, the best clearly marked to avoid a long time myself confused.

image

- the frequency setting scheduled task.

Note: set according to your specific needs. For example, I know almost reptilian Script 2 hours, and the statistical analysis of the script once a day can be.

Every 2 hours for a scheduled task may be selected per day, may be added later in a plurality of periods. For example, every day 6,8,10,12,14 point, etc. are executed. Beginning to set up a point in time can be. Then add other point in time. It will be described in detail below.

For python script, its types are: program.

image

  • Programs and scripts: here to fill in the installation path of the python. Click Browse "to search ......" selection interface will pop up automatically.
  • Add parameter (Optional) A: I'm here to fill the absolute path of reptile python script. For example, my script is:

C:\Users\username\python_side_projects\crawler\crawler_base\zhihu_topic_monitor_exe.py

image

系统默认打开的路径,并没有我想打开的 python.exe 怎么办?简单……往下看。

image

这里遇到一个小知识点:

知识点:如何查找 python 安装在哪里?

启动cmd(命令行提示符),输入:where python 即可。下面看到,我的电脑上装了两个python,选择你常用的那个版本即可。

image

按照上述路径提示,打开对应文件夹,选中 python.exe 即可。

image

按照以上步骤设定好计划任务的属性,点击完成就行啦。等等……我刚才希望爬虫脚本每隔2小时就执行一次,如何设定呢?

小技巧:每隔2小时就运行一次,如何设定计划任务。

先新建一条普通的计划任务,或选择已有的计划任务,选择“属性”打开计划任务的属性界面。

image

在“触发器”这个页签,按需求,添加更多时间点,然后提交完成即可。

image

经验:遇到报错所指定的账户名称无效,怎么办?

image

简单来说,在计划任务属性页面,点击“更改用户或组”,输入用户名(比如我的“75801”),然后点击“检查名称”,再点击“确定”提交,就可以了。详细的图文说明,请挪步我的另外一篇整理:https://blog.csdn.net/qiaoanlu/article/details/100731220

PRESS.one signature of this article:
https://press.one/file/v?s=950fee0e9bbae05fcf407c11a83a0f99dc40cc426b016be34d3298ac8c16a3673693092b79536eddfdca342c7173e766fd956e244e04d0936699a78f161bc0de00&h=94e2717c89ab8937a8dbdae8e1092e46c0c402faf4925e2281f2e261c24e2dd9&a=ed73e900e209def08ff03a2e3fadbac99af087c0&f=P1&v=3

Guess you like

Origin www.cnblogs.com/jjliu/p/11505720.html