skybert's Blog

skybert's Avatar Image
Coder of systems, lover of languages, follower of Christ. 台灣女婿
← All posts

For long-running shell scripts, I find this command useful for seeing what they’re doing:

$ watch 'pstree -p <pid>  -l -U -a'

Example output:

bash,730829 /usr/local/sbin/update-foo
  └─sh,816279 /usr/bin/freight-cache --conf /etc/foo.conf
      ├─sh,816302 /usr/bin/freight-cache --conf /etc/foo.conf
      │   └─sort,816305 -V
      └─sh,816303 /usr/bin/freight-cache --conf /etc/foo.conf

For maximum observability of your own shell commands you start, can you of course use bash -x and enrich the output with PS4, but the above works for any command, and one that’s already running.

#bash #debugging #unix

To like or reply, open original post on Emacs.ch