How can I interrupt os.system(cmd)?

C

Carl

Dear friends,

I have written a small Python program that executes "cmd" via
os.system(cmd).

My problem is that "cmd" runs on forever.

More specifically, I want to run "cmd" for one hour on a regular day-to-day
basis by using crontab as a scheduler.

What options do I have to control execution of external programs from
Python?

Carl
 
M

Mathias Waack

Carl said:
What options do I have to control execution of external programs
from Python?

You have the same options as your OS offers. At least under Unix you
can run a command by using one of the popen()-functions or using the
commands module (I would suggest the latter for you). All these
procedures give you the process id (pid) of the started process. You
can wait() for this process or you can control it by sending it
signals using the kill() function. The python docs contains all
information necessary to use these functions. Read the pages about
the modules os, popen and commands. Most of these functions should
be available under all OS.

Mathias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top