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