10

I'm trying to schedule run multiple pythons using batch file.

For example there are my python files that I want to schedule run them on the daily basis

D:\py\s1.py
D:\py\s2.py

now how can I combine these two files into a .bat, so that I can schedule run these two file using python.exe (C:\python27\python.exe) at the same time.

Thank you

1
  • Well, there is the option of calling them natively from a parent Python script too. But even if you don't want to do that, this is a pretty rudimentary batch script. Are you having specific problems with environment or something, or do you just want a ready-made custom solution done for you?
    – Silas Ray
    Dec 14, 2012 at 14:38

1 Answer 1

25

Method 1: Bat file.

If you have python in the PATH Environment variable:

start python D:\py\s1.py
start python D:\py\s2.py

Else literal path

start C:\python27\python.exe D:\py\s1.py
start C:\python27\python.exe D:\py\s2.py

Note that this will not wait for a return from either execution. Note, do not forget to add quotations around the path strings if they contain spaces or special characters.

See start /? for more help and options.

Method 2: Two different Scheduled Tasks

Create two separate scheduled tasks that start at the same time each calling python to run one of the scripts.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.