Bash/ps: get pid of a running “myscript.sh” child of a certain process
Question
in bash I need to get the pid of a running process whose I know name and parent pid.
In ps' manual I read you can select processes using such arguments:
--ppid <pidlist>
and
-C <cmdlist>
So, in order to get the pid of running "myscript.sh" child of $parentpid, I tried:
ps -C myscript.sh --ppid $parentpid -o pid --no-headers
but I got all the children processes of $parentpid. The -C argument seems to be ignored also if I swap it with the other one.
Any help, expecially avoiding sed and grep and the like? Thank you!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow