I want to know currently running background process by using unix "jobs" command in python environment.
I tried using import os os.system('jobs') but it not works for me
|
The equivalent concept in Python would be objects created using the subprocess module. Using that module, you can start, kill, and wait for subprocesses. For example, if you create multiple subprocesses using |
|||||||||||||||||
|
Jobs are an internal notion of the shell. A job is in fact a subprocess that the shell remembers having launched. You can't manipulate a shell's job table from outside that shell. You can manipulate the processes as such. It's impossible to tell whether a process is a job of a given shell, all you can do is guess. You can list the processes whose parent ID is the shell's PID; you can list processes that are process group leaders and that are running on the same terminal as the shell. See this Stack Overflow question for some ways to obtain information about processes in Python. If you need to control jobs in your Python script, you should really launch and manage the processes from the Python script, if at all possible. All you need is in the |
|||
|