Results 1 to 6 of 6
Say I want to run a command says top command,
I need to get process id after invoking it. something like
$pid= top
$echo $pid #pid of just invoked command
...
- 12-03-2009 #1
[SOLVED] How to get process id - pid ?
Say I want to run a command says top command,
I need to get process id after invoking it. something like
$pid= top
$echo $pid #pid of just invoked command
I don't want to use something like ps aux | grep top - since I have several top command running in parallel.
Thanks- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 12-03-2009 #2Just Joined!
- Join Date
- Jan 2005
- Posts
- 17
- 12-03-2009 #3
I'm testing an application ...
start application1 -> get pid -> do some testing -> kill process using pid
start application2 -> get pid -> do some testing -> kill process using pid
application1,application2 ... are all same process created by same user.- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 12-03-2009 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
On most distributions there is a command pidof which will return the process id's of named applications. If you want the pid of a background process when you start it, then you can use the shell variable $! which will return the pid of the last background process started in that shell. This is useful for shell scripts.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 12-04-2009 #5- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 12-04-2009 #6Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,970
Glad to be of service!
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!



