Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #1174

Re: Getting the PID of a process ID

From Bill Marcum <bill@lat.localnet>
Newsgroups comp.os.linux.misc
Subject Re: Getting the PID of a process ID
Date 2011-05-19 13:29 -0400
Organization Mankind for Ethical Animal Treatment
Message-ID <slrnitaks3.5u2.bill@lat.localnet> (permalink)
References <58a25ff3-28fa-4662-9455-5bbc2db02946@x1g2000yqb.googlegroups.com>

Show all headers | View raw


On 2011-05-19, laredotornado <laredotornado@zipmail.com> wrote:
> Hi,
>
> I'm using Ubuntu 11.04.  How do I get the process ID of a process I
> just kicked off in a script?  I have
>
>         /usr/bin/Xvfb :15 -ac -screen 0 1024x768x16 &
>         XVFB_PID=$!
>         echo $XVFB_PID > /var/run/xvfb.pid
>         su selenium -c 'java -jar /opt/selenium/selenium-server-
> standalone-2.0b3.jar -userExtensions /opt/selenium/user-extensions.js
>> /var/log/se_rc_server.log 2>&1 &'
>         PID=$!
>         echo $PID > /var/run/selenium-server.pid
>
> However both the XVFB_PID and PID are the same value, and neither is
> the value of what was just kicked off.  Appreciate pointers on how to
> store the correct PID in the variables.  Thanks, - Dave

$! is the PID of the last process launched with "&" by the current shell.
If the shell launches a process that forks another process, you might
need some other means to find the PID.  pidof and pgrep are useful but
I don't know if they are standard.


-- 
Linux and Windows both win.
Best Documentary Feature: March of the Penguins
Best Picture: Crash

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Getting the PID of a process ID laredotornado <laredotornado@zipmail.com> - 2011-05-19 06:47 -0700
  Re: Getting the PID of a process ID gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-19 16:53 +0000
    Re: Getting the PID of a process ID "laredotornado@zipmail.com" <laredotornado@gmail.com> - 2011-05-19 10:10 -0700
  Re: Getting the PID of a process ID Huibert Bol <huibert.bol@quicknet.nl> - 2011-05-19 19:41 +0200
    Re: Getting the PID of a process ID laredotornado <laredotornado@zipmail.com> - 2011-05-19 11:11 -0700
  Re: Getting the PID of a process ID Bill Marcum <bill@lat.localnet> - 2011-05-19 13:29 -0400

csiph-web