{"id":19413091,"url":"https://github.com/joknarf/pgtree","last_synced_at":"2025-12-28T21:38:28.445Z","repository":{"id":45676507,"uuid":"286058853","full_name":"joknarf/pgtree","owner":"joknarf","description":"Unix process hierachy tree for specific processes (mixed pgrep + pstree)","archived":false,"fork":false,"pushed_at":"2025-04-22T07:00:00.000Z","size":149,"stargazers_count":30,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T23:02:33.649Z","etag":null,"topics":["cli","command-line","hierarchy","linux","pgrep","pkill","process","pstree","sysadmin","tool","tree","unix"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joknarf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-08T14:30:13.000Z","updated_at":"2025-04-22T07:00:04.000Z","dependencies_parsed_at":"2024-01-16T00:22:33.990Z","dependency_job_id":"10077aad-4f97-4ba3-9688-7981d26a843b","html_url":"https://github.com/joknarf/pgtree","commit_stats":{"total_commits":196,"total_committers":4,"mean_commits":49.0,"dds":0.4744897959183674,"last_synced_commit":"14c600106df7bef9ef93b330801092b61f2dd834"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/joknarf/pgtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fpgtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fpgtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fpgtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fpgtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joknarf","download_url":"https://codeload.github.com/joknarf/pgtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joknarf%2Fpgtree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264390670,"owners_count":23600560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","hierarchy","linux","pgrep","pkill","process","pstree","sysadmin","tool","tree","unix"],"created_at":"2024-11-10T12:30:43.841Z","updated_at":"2025-12-28T21:38:28.440Z","avatar_url":"https://github.com/joknarf.png","language":"Shell","readme":"[![Joknarf Tools](https://img.shields.io/badge/Joknarf%20Tools-Visit-darkgreen?logo=github)](https://joknarf.github.io/joknarf-tools)\n[![Codecov](https://codecov.io/github/joknarf/pgtree/coverage.svg?branch=master)](https://codecov.io/gh/joknarf/pgtree)\n[![Upload Python Package](https://github.com/joknarf/pgtree/workflows/Upload%20Python%20Package/badge.svg)](https://github.com/joknarf/pgtree/actions?query=workflow%3A%22Upload+Python+Package%22)\n[![Pypi version](https://img.shields.io/pypi/v/pgtree.svg?logo=pypi)](https://pypi.org/project/pgtree/)\n[![Python versions](https://img.shields.io/badge/python-2.3+%20|%203.x-blue.svg?logo=python)](https://shields.io/)\n[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://shields.io/)\n[![Downloads](https://pepy.tech/badge/pgtree)](https://pepy.tech/project/pgtree)\n\n# pgtree\nUnix process hierachy tree display for specific processes (kind of mixed pgrep + pstree)\n\npgtree is also able to send signal to found processes and all their children\n\nThe purpose is to have the tool working out of the box on any Unix box, using the default OS python installed, without installing anything else.\nThe code must be compatible with python 2.x + 3.x\n\nShould work on any Unix that can execute :\n```\n# /usr/bin/pgrep \n# /usr/bin/ps ax -o pid,ppid,stime,user,ucomm,args\n```\n\nif `pgrep` command not available (AIX), pgtree uses built-in pgrep (`-f -i -x -u \u003cuser\u003e` supported).\n\n`-T` option to display threads only works if `ps ax -T -o spid,ppid` available on system (ubuntu/redhat...)\n\n_pgtree Tested on various versions of RedHat / CentOS / Ubuntu / Debian / Suse / FreeBSD / ArchLinux / MacOS / Solaris / AIX including old versions_\n\n_(uses -o fname on Solaris)_\n\n## Installation\nFYI, the `pgtree/pgtree.py` is standalone and can be directly copied/used anywhere without any installation.\n\ninstallation using pip:\n```\n# pip install pgtree\n```\n\nor use your prefered method according to your OS:\n\n```\nbrew install joknarf/tools/pgtree\n```\n\n```\nsudo dnf install https://github.com/joknarf/pgtree/releases/latest/download/pgtree.rpm\n```\n\n```\ncurl -OL https://github.com/joknarf/pgtree/releases/latest/download/pgtree.deb\nsudo dpkg -i pgtree.deb\n```\n\n```\ncurl -OL https://github.com/joknarf/pgtree/releases/latest/download/pgtree.apk\nsudo apk add --allow-untrusted pgtree.apk\n```\n\n```\ncurl -OL https://github.com/joknarf/pgtree/releases/latest/download/pgtree.pkg\nsudo installer -pkg pgtree.pkg -target /\n```\n\n## Usage\n```\n# pgtree -h\n    usage: pgtree.py [-W] [-RIya] [-C \u003cwhen\u003e] [-O \u003cpsfield\u003e] [-c|-k|-K] [-1|-p \u003cpid1\u003e,...|\u003cpgrep args\u003e]\n\n    -I : use -o uid instead of -o user for ps command\n         (if uid/user mapping is broken ps command can be stuck)\n    -c : display processes and children only \n    -k : kill -TERM processes and children\n    -K : kill -KILL processes and children\n    -y : do not ask for confirmation to kill\n    -R : force use of internal pgrep\n    -C : color preference : y/yes/always or n/no/never (default auto)\n    -w : tty wrap text : y/yes or n/no (default y)\n    -W : watch and follow process tree every 2s\n    -a : use ascii characters\n    -T : display threads (ps -T)\n    -O \u003cpsfield\u003e[,psfield,...] : display multiple \u003cpsfield\u003e instead of 'stime' in output\n                   \u003cpsfield\u003e must be valid with ps -o \u003cpsfield\u003e command\n\n    by default display full process hierarchy (parents + children of selected processes)\n\n    -p \u003cpids\u003e : select processes pids to display hierarchy (default 0)\n    -1 : display hierachy children of pid 1 (not including pid 0)\n    \u003cpgrep args\u003e : use pgrep to select processes (see pgrep -h)\n\n    found pids are prefixed with ▶\n```\n## Examples\nshow all parents and children of processes matching `bash`\n\n\u003cimg alt=\"# pgtree bash\" src=\"https://user-images.githubusercontent.com/10117818/91555007-7d69a900-e930-11ea-98a2-8d81b7fdf0d3.png\" width=\"850px\"\u003e\n\nshow processes matching `bash` and their children\n\n\u003cimg alt=\"# pgtree -c bash\" src=\"https://user-images.githubusercontent.com/10117818/91555156-c15cae00-e930-11ea-9479-7c9b2c7b249e.png\" width=\"850px\"\u003e\n\nkill all `sh` processes of user joknarf and their children\n\n\u003cimg alt=\"#pgtree -k -u joknarf -x sh\" src=\"https://user-images.githubusercontent.com/10117818/91555424-48aa2180-e931-11ea-8f19-6054458aa79c.png\" width=\"850px\"\u003e\n\nCustomize ps output fields:\n\n\u003cimg width=\"719\" alt=\"image\" src=\"https://user-images.githubusercontent.com/10117818/215278250-83440d9c-f1a1-4ac7-afa5-db4f1b1c6395.png\"\u003e\n\nPut default options in PGTREE env variable:\n```\n# export PGTREE='-1 -O %cpu,stime -C y'\n# pgtree\n```\n\nUse watch utility to follow process tree:\n```\n# pgtree -W bash\n```\n![image](https://user-images.githubusercontent.com/10117818/215317322-7df4559c-ccf4-41f6-b008-55d1fc8f0bb7.png)\n\n## Demo\n\n\u003cimg alt=\"output\" src=\"https://user-images.githubusercontent.com/10117818/91558307-64fc8d00-e936-11ea-85bc-08eae29a58ce.gif\" width=\"850px\"\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoknarf%2Fpgtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoknarf%2Fpgtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoknarf%2Fpgtree/lists"}