Running processes¶
-
pshell.
find_procs_by_cmdline
(*cmdlines)¶ Search all processes that have a partial match for at least one of the given command lines. Command lines are parsed through
resolve_env()
.For example, the command:
find_procs_by_cmdline('$MYROOT')
will return a match for the following processes:
$MYROOT/static/scripts/something.sh
tail -f $LOGDIR/mylog.log
myservice.sh -c /algodata/someuser/root/cfg/myservice.cfg
where:
MYROOT=/algodata/someuser/root
LOGDIR=/algodata/someuser/root/log
This method will only return processes for the current user.
Warning
Invoking this with relative paths can give erroneous results. For example, invoking it with ‘foo’ will match, for example, ‘foo.pl’, ‘find_foos.sh’, and ‘vim foobar.cfg’.
Warning
This command can’t match commands invoked with a relative path if the search parameter is an absolute path. e.g.
find_procs_by_cmdline('$MYROOT')
won’t be able to matchcd $MYROOT/bin && ./myscript
.Parameters: cmdlines – one or more paths command lines to search for Returns: list of psutil.Process
objects