Re: "pidof" on a process (which was ran by passing arguments from the command line)
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: Sun, 3 Jul 2005 18:23:37 -0400
On 2005-07-03, email@example.com wrote:
> This question may be relevant to running "pidof" generally on processes
> which were run by passing an argument in the command line;
> To me it occurred with python.
> I am running a python script of xen.
> I want to be able to get the pid of that process by running "pidof".
> The command line for running the script is
> /xend start
> (but in fact it runs "python ./xend start" because the first line in
> script is "#!/usr/bin/env python".)
> ("python ./xend start"" is also what we get (among other processes)
> ps -aux |grep python for that specific process I am talkng about).
> I want to be able to get the pid of that process by runnning "pidof".
> pidof "python ./xend start" gives nothing (in Bash and in Tcshell).
> pidof "python" gives 4 processes (one of them is the requested one).
> 2502 is the process id of the wanted process.
> cat /proc/2502/cmdline
> but trying pidof "python./xendstart" (also with one apostrphe or none
> at all)
> gave nothing.
> Also "pidof -x xend" does not help : it returns an empty string.
> Any idea?
pidof obviously does not do what you want, so you need to use a
different command (or combine pidof with other commands).
What wrong with:
set -- $( ps ax | grep 'python.*\./xend' )
-- Chris F.A. Johnson <http://cfaj.freeshell.org> ================================================================== Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress <http://www.torfree.net/~chris/books/cfaj/ssr.html>