473,396 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

get pid of a nohup command in Python

I'm new to Python and am evaluating moving a project from Tcl/Tk to
Python and am stuck on one issue. How can I nohup (or any detached
task for that matter) a process and get its PID in Python. The obvious
route of (with a trivial example)

os.system("nohup ls junk &")

returns the status of the command execution (ie. 0). I wish to get the
PID output of the command (e.g. 16617). All the other commands spawn**
also seem to return the execution status not the PID. This is a
showstopper so any help appreciated.

Feb 13 '07 #1
1 3673
En Tue, 13 Feb 2007 01:52:57 -0300, <g.*********@telluricresearch.com>
escribió:
I'm new to Python and am evaluating moving a project from Tcl/Tk to
Python and am stuck on one issue. How can I nohup (or any detached
task for that matter) a process and get its PID in Python. The obvious
route of (with a trivial example)

os.system("nohup ls junk &")

returns the status of the command execution (ie. 0). I wish to get the
PID output of the command (e.g. 16617). All the other commands spawn**
also seem to return the execution status not the PID. This is a
showstopper so any help appreciated.
The spawn* family will return the pid if you use the P_NOWAIT flag.
But the best way is to use the subprocess module; Popen objects have a pid
attribute.

http://docs.python.org/lib/module-subprocess.html

--
Gabriel Genellina

Feb 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nosmada | last post by:
Here is my php command that I am using from an SSH Command line prompt (apache/linux server): php scriptname.php all If this were cgi I would normally execute the command like this: nohup...
8
by: Joe | last post by:
I'm using Python 2.4 on Windows XP SP2. I'm trying to receive a command line argument that is a newline (\n) Here is the command line to use sample.py "\n" Here is a sample.py script
0
by: andrea valle | last post by:
Hi to all, I need to run a program from inside python (substantially, algorithmic batch processing). I'm on mac osx 10.3.8 with python 2.3 framework and macpython. Trying to use exec*, I...
1
by: Joannes Vermorel [MVS] | last post by:
I am implementing a .Net application (scientific computing) that basically requires a couple of days to terminate on a single desktop. Until now, I was using Mono (a .Net port) to run it on a Linux...
7
by: Steve M | last post by:
I'm trying to invoke a Java command-line program from my Python program on Windows XP. I cannot get the paths in one of the arguments to work right. The instructions for the program describe the...
4
by: kwatch | last post by:
Hi, I have a question about os.times(). os.times() returns a tuple containing user time and system time, but it is not matched to the result of 'time' command. For example, os.times() reports...
9
by: Endless Story | last post by:
My last version of Python was 2.4, running smoothly on XP with path c: \Python24 - no need even to include this path in PATH; everything worked as it's supposed to at the command line. Just...
13
by: c3950ig | last post by:
Hi, I am python newbie and the command prompt is having an issue with python. I installed python 2.4.4 onto my windows machine, opened a command prompt window, and typed python to start the...
2
by: John [H2O] | last post by:
Just a quick question.. what do I need to do so that my print statements are caught by nohup?? Yes, I should probably be 'logging'... but hey.. Thanks! -- View this message in context:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.