Scheduling imports
File imports can be scheduled to be executed regularly using for example Windows Task Scheduler. Follow these steps:
- Open the Task Scheduler application
- Select Create Basic Task
- Specify name and task trigger (interval)
- Select the Start program action
- Set Program/script to the
pythonw.exe
located in the virtual environment you want to use (i.e.<path to venv>\scripts\pythonw.exe
- Set Add arguments to your Python import script
Tip!
Test your script from the command prompt before scheduling it to make sure it works properly.
Tip!
When running with pythonw.exe
, no console window will be displayed so you'll not get much feedback as to what's going on. This is probably what you want in production scenarios where you can use logs to report errors.
While you're setting up the scheduled task you can use python.exe
instead. This displays a console window where you can see print()
statements and even debug your scripts from within the task scheduler.
Note!
Unless you point out a specific starting or working folder for the scheduled task it will be C:\
.