[Klug-general] Looking at shell scripts during execution

David Halliday david.halliday at gmail.com
Wed Nov 21 16:24:06 UTC 2012


Hi, I recently had an issue where I wanted to ge some visibility on what
some large script which included various tasks, functions, sub scripts
etc... were doing.

Mostly I wanted another way to view where a script was, what it was doing
while it was still running. While the scripts do produce log files I wanted
to view a snapshot of this point in time.

ps does contain all this data but managing it is sometimes a little
difficult, passing the filters to get the granularity you require and
getting the formatting needed wasn't easy.

So I created a pair of bash functions that I can include in a text file,
then pull them into the command line and call them whenever I wanted an
overview of my scripts.

I have put the code on my wiki, hope this might be of use to someone else:
http://david-halliday.co.uk/wiki/doku.php?id=linux:bits:process_tree_with_ps

I just have to include the functions on the command line as:
. /path/to/script.sh

then call the main function to get all shell scripts and output their
details:
dh_script_view

This should be fairly easy to understand and modify for viewing sub
processes of any process you chose handing it's pid to the function:
dh_pidtree
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/kent/attachments/20121121/8539bf1a/attachment.html>


More information about the Kent mailing list