Run Python Script from Windows Task Scheduler

Schedule Python Script from Windows Task Scheduler Example

python task schedulerWindows Task Scheduler is a convenient method to schedule a quick python script to execute on a schedule. Whether your on a computer or server, this tutorial will put you on the right track.

It can be tricky to execute a python script from the Task Scheduler because a Python program requires an interpreter. You’ll notice they’re two options in the steps below to enter the “Action”. The options depend if your script contains an extension (.py) or if that extension is associated (opens with) with the Python interpreter.

Start Windows Task Scheduler

Control Panel > Administrative Tools

Create Basic Task
    1. Enter Task Name
    2. Select Trigger (e.g., Daily)
    3. Enter Action > Start a program (if .py ext is not associated)
        Program/script: C:\path\to\python27\python.exe
        Add arguments: myscript.py
        Start in: C:\path\to\script
    4. Enter Action > Start a program (if .py ext is associated)
        Program/script: myscript.py
        Add arguments: -flag (optional)
        Start in: C:\path\to\script
Test Scheduled Script
    1. Open task scheduler
    2. Highlight task name
    3. Select Action > Run

See also:
Python Jinja2 Template: YAML File Cisco Example
Bask One-liners: Linux, If, Else, For loop, Sed, Awk