Schedule a Python script via batch on windows (using Anaconda)

I would be a bit careful in calling python directly through environment as one never knows if the internals for activate function has changed.

I’m just using basic bat-script to help me out.

SET log_file=%cd%\logfile.txt
call C:\Anaconda3\Scripts\activate.bat
cd \script_directory
python script.py arg1 arg2 > %log_file%

This script saves the log-file wherever the bat is run from, calls the right environment through activate (in this case the standard) and directs all the stdout into log-file for further investigation.

Then just point your Windows Task Scheduler to the script and set the home directory where you want the log-file to appear.

Leave a Comment

techhipbettruvabetnorabahisbahis forumu