This post will show you how to schedule a Python Script execution using Windows Task Scheduler. This will help you automate tasks using Python on Windows.
Use crontab for python script automation on Mac.
With python scripts, you could extract data from Google Search Console and Google Analytics every day and send yourself a weekly email report. You could log all your keywords every day or automate your keywords research.
Before we can cover all that, we need to learn how to use Windows Task Scheduler.
What is Windows Task Scheduler?
Windows Task Scheduler is a component that gives the ability to schedule and automate tasks in Windows by running scripts or programs automatically at a given moment.
Get Started Using Windows Task Scheduler
To run your python scheduler you will need to create a task, create an action, add the path to your python executable file and to you python script and add a trigger to schedule your script.
1. Create Your First Task
Search for “Task Scheduler”.
This will open the Windows Task Scheduler GUI.
Go to Actions > Create Task…
Give a name
2. Create an Action
Go to Actions > New
3. Add the Python Executable File to the Program Script
Find the Python Path using
where python in the command line.
From the command prompt copy the script to use in the action.
or in my case
In Program/Script, add the path that you have copied from the command line.
4. Add the Path to Your Python Script in the Arguments
Go to the folder where your Python script is located. Right-click on the file and select
Copy as path.
If you have a file located at this location.
"Add arguments (optional)” box, you will add the name of your python file.
"Start in (optional)" box, you will add the location of your python file.
Note: Alternatively, you could create a batch file combining your Python script and Python executable file in a
5. Trigger Your Script Execution
Go to “Triggers” > New
Choose the repetition that you want. Here you can schedule python scripts to run daily, weekly, monthly or just one time.
Once, you have set this up, your trigger is now active and your python script will run automatically every day.
Task Scheduler Python Script Automation FAQs
📙Can Task Scheduler run a Python script?
🐍How to schedule a Python script with Task Scheduler?
⭐Does Task Scheduler work when computer is sleeping?
That’s it, you now know how to run a Python script automatically using Windows Task Scheduler.