Files
homebrew-notes/witr.md
Timmy e9bff6b2af docs: add witr CLI notes
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 21:20:34 +08:00

1.7 KiB

witr CLI 文件

透過追溯行程祖先,解釋某個 process 或 port 為什麼在跑。版本 v0.3.3。

專案:https://github.com/pranshuparmar/witr

安裝

brew install witr   # macOS / Linux,來自 homebrew-core

基本用法

witr nginx          # 依名稱(模糊比對)查行程
witr nginx node     # 查多個

可混合輸入,旗標多數可重複:

witr nginx --pid 1234 --port 8080
witr --port 8080 --port 3000

查詢方式

旗標 說明
[name...] 依行程名稱查(預設模糊比對)
-p, --pid 依 PID 查(可重複)
-o, --port 依監聽的 port 查(可重複)
-f, --file 依被開啟的檔案查(可重複)
-c, --container 依容器名稱查(可重複)
-x, --exact 精確比對,不做子字串搜尋

輸出控制

旗標 說明
-t, --tree 只顯示祖先(樹狀:誰啟動了誰)
-s, --short 只顯示祖先(單行,適合腳本)
--warnings 只顯示警告(可疑的 env、參數、父行程)
--env 顯示行程的環境變數
--verbose 顯示延伸資訊(記憶體、I/O、file descriptors)
--json 輸出機器可讀的 JSON
--no-color 關閉色彩(CI 或 pipe 時用)
-i, --interactive 互動模式(TUI)
-h, --help 顯示說明
-v, --version 顯示版本

範例

witr --port 5432              # 找占用該 port 的行程
witr --file /var/lib/dpkg/lock   # 找開著該檔案的行程
witr postgres --tree         # 看完整啟動鏈
witr docker --warnings       # 只看可疑處
witr --port 8080 --env --json   # 組合:port + 環境變數 + JSON