I'm trying to write a bash script which would log all descendants process information in below format but I have to log the info only when a process has more than six descendants process.
PID | PPID | Level |
---|---|---|
10 | 9 | 1 (indicates child) |
9 | 8 | 2 (indicates parent) |
8 | 7 | 3 (indicates grand parent) |
Pstree -ps 10 should display:
dummy1---dummy2---dummy3---dummy4---dummy5---dummy6---dummy7
How to trigger dummy process in above manner?
Frankly I have no idea about bash script, only thing i was able to do was display PID's of a particular user.
while read -r processId;
do
echo $processId
done <<< "$(ps -u $USER -o pid)"
I need to loop each PID & check if it has more than six descendants but before that I want to manually trigger six descendants process to start & test my script.