Schedule Python Script - Windows 7

Btibert3 picture Btibert3 · Apr 28, 2010 · Viewed 73.9k times · Source

I have a python script which I would like to run at regular intervals. I am running windows 7. What is the best way to accomplish this? Easiest way?

Answer

Glen Robertson picture Glen Robertson · Apr 28, 2010

You can do it in the command line as follows:

schtasks /Create /SC HOURLY /TN PythonTask /TR "PATH_TO_PYTHON_EXE PATH_TO_PYTHON_SCRIPT"

That will create an hourly task called 'PythonTask'. You can replace HOURLY with DAILY, WEEKLY etc. PATH_TO_PYTHON_EXE will be something like: C:\python25\python.exe. Check out more examples by writing this in the command line:

schtasks /?

Otherwise you can open the Task Scheduler and do it through the GUI. Hope this helps.