running a python script in the background

Arun arun.sivakumaran at
Sat Oct 30 05:23:47 CEST 2004


This is a scripting question, but since I am writing the script in
python I am posting this question here:

I have a python script that runs a simulator (that was written in c++,
so I use the system() function to run the simulator) over a list of
config files. I want the python script to itself run as well as start
the simulations totally in the background (the simulations run for a
day or two, so basically I want to start them in background and log

The structure of script is somewhat like this:

Create the config files

Loop through the list of config files:
     system("simulator configfile");


Now if I start the script in the background with " &", it
doesn't work. I figure the reason is the system() call spawns the
simulator in the foreground.

If I change the system call to system("simulator configfile &"), then
the script will spawn off the simulator with the config files all at

Is there a way I can make this all run in the background, while at the
same time ensuring that only one instance of the simulator is running?


More information about the Python-list mailing list