While the Task Scheduler is a fine choice for infrequent runs (e.g. daily), you may be better off with a
rock-solid
Windows Service
that can provide observability, accountability, and 100% uptime.
And it takes less than 5 minutes to set that up. Let's show you how, step by step.
-
If necessary, download and install Python, along with any extensions you require:
Ensure that your script runs normally from a command prompt.
If your Python program doesn't work now, it won't work as a Windows Service either!
-
Download and install AlwaysUp, if necessary.
-
Start AlwaysUp.
-
Select Application > Advisor to launch the Application Advisor:
-
Click Next to move past the welcome screen:
-
Choose Python from the list of applications and click Next to proceed:
-
The Advisor will examine your system for a few seconds and collect information about your Python installation.
After that, you'll be prompted to enter the full path to your Python script (*.py).
You can either type it in or click the ... button to browse your hard drive for the file:
Click Next to move on.
-
On this screen, you'll be prompted to enter the password of your Windows account. We know Python works in that context:
Click Next to move on.
-
At this point, AlwaysUp has everything it needs and is ready to show you all the settings it has chosen. Click Next to proceed:
-
The Add Application window contains all the recommended settings for running your Python script 24x7 after your computer boots.
Feel free to cycle through the tabs and review the options that have been chosen:
-
In this default setup, AlwaysUp will automatically restart your Python app immediately after it stops. The effect is to run your script continuously, without any pauses.
If that's not what you want — say you want to run your script every few minutes instead — you should make the following changes:
Switch to the Restart tab.
Adjust the controls to reflect how often AlwaysUp should run your script. For example, here's how we said to run our script every 5 minutes:
Activate the Minimize event logging option, to reduce chatter as your script starts and stops frequently.
Check the Don't panic box, especially if your script can exit very quickly.
-
When you're ready, click Save to record your new Python service:
-
In a few seconds, a new entry for your Python program will show up in the AlwaysUp window. Your script is now installed as a Windows Service. Congratulations!
However, the state will be "Stopped" because the service isn't running yet:
-
Finally, to launch your Python script as a service, choose Application > Start.
The entry will transition to "Running" and your script will be active in the background
(in Session 0):
If you decided to run your app every few minutes (in step 11), you may occasionally see it waiting too:
-
And that's it! Next time your computer boots, your Python program will start immediately, before anyone logs on, and run continuously in the background.
We encourage you to edit Python in AlwaysUp and explore the many other settings that may be appropriate for your environment.
For example, you can: