Skip to content

Unix process tree hierachy for specific processes with awk

License

Notifications You must be signed in to change notification settings

joknarf/pgtreeawk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

pgtreeawk

Unix process hierachy tree display for specific processes (kind of mixed pgrep + pstree)

awk version of pgtree

pgtree is also able to send signal to found processes and all their children

Should work on any Unix that can execute :

# /usr/bin/pgrep 
# /usr/bin/ps -e -o pid,ppid,user,comm,args

Usage

# pgtree -h
    usage: pgtree [-ICya] [-c|-k|-K] [-p <pid1>,...|<pgrep args>]

    -I : use -o uid instead of -o user for ps command
         (if uid/user mapping is broken ps command can be stuck)
    -c : display processes and children only
    -k : kill -TERM processes and children
    -K : kill -KILL processes and children
    -y : do not ask for confirmation to kill
    -C : no color (default colored output on tty)
    -a : use ascii characters

    by default display full process hierarchy (parents + children of selected processes)

    -p <pids> : select processes pids to display hierarchy (default 1)
    <pgrep args> : use pgrep to select processes (see pgrep -h)

    found pids are prefixed with ▶

Examples

show all parents and children of processes matching bash

# pgtree bash

show processes matching bash and their children

# pgtree -c bash

kill all sh processes of user joknarf and their children

#pgtree -k -u joknarf -x sh

Demo

output

About

Unix process tree hierachy for specific processes with awk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages