Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call / run multiple python scripts from batch file in window xp / 7

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

like image 238
JPC Avatar asked Dec 14 '12 14:12

JPC


People also ask

How do I run a python script in Windows XP?

Press Ctrl + R , then type python.py to run your Python script.

How do I run multiple python scripts at once?

Using terminal - this is the simplest way to do it . You execute any python script as “$python a.py”. Now, if you want multiple scripts, you can either open up multiple terminals and run diffent programs on each or, in the same terminal “$ python a.py&b.py&c.py” . This will execute all programs from the same terminal.

How many python programs can run at the same time?

You can run only one Python application per interpreter, and you can only run one interpreter per process. If you want to run multiple applications then you will need to run multiple processes.


1 Answers

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.

like image 105
David Ruhmann Avatar answered Sep 19 '22 15:09

David Ruhmann