Note: ArcGIS Pro 2.5 users can easily automate scripts and models within Pro. See the documentation here.
Here are the steps to execute a python script using Windows Task Scheduler. This is very useful when you need to execute a script at a prescribed time, or when you need to continuously execute a script (i.e. every 15 minutes). The below steps must be run from a server that has python installed.
1. Go Start and search for Task Scheduler
2. Under the Actions pane on the right, click Create Task
3. Specify a Name for the task, Security Options, and set the Configure for to the appropriate Operating System
4. Click the Triggers tab and then click New
5. Specify the schedule properties. For example, if you wanted to execute a python script every 15 minutes, set the Settings to Daily, then specify a Start date and time. Under the Advanced settings, check Repeat task every and set this to a value. Then set the for a duration of setting. The below example will execute the script every 15 minutes indefinitely starting on 3/19/2020 at 9:00:00 AM.
6. Click the Actions tab and click New
7. Set the Action to Start a program. The Program/Script needs to be set to the path of your python executable (python.exe). In the below example, the script will be executed using Python 3.x, so I will specify the path to the python.exe for my ArcGIS Pro install. This is generally located at: "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe".
The Add argument will be the path to my script: "C:\Projects\Scripts\NWM_UpdateFlow.py"
8. Optionally, set any settings on the Conditions and Settings tab, then click OK to create the task. If you chose the option to have the task execute whether the user is logged on or not, you will be presented with a dialog to enter your credentials. The task will then be ready to execute at the Start time: