1

I was looking for a linux command to find the parent process id. When I use the following command ps- ef | grep jboos

It returns all process ids including chile and some other information. What I am looging for is to filter out child ids and other information and return only parent id. So that calling app can kill all the running processes by just killing parent.

Thanks

user509755
  • 2,941
  • 10
  • 48
  • 82

2 Answers2

7

The l (lowercase L) option to ps will add the PPID column to the output.

Asclepius
  • 57,944
  • 17
  • 167
  • 143
kclair
  • 2,124
  • 1
  • 14
  • 18
3

getppid is the function that you require. In bash it is $PPID

eg

#!/bin/bash

echo $PPID;
Ed Heal
  • 59,252
  • 17
  • 87
  • 127