<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    My fave for running and monitoring scripts is GNU screen.<br>
    With it you can just run the script in screen sessions and attach to
    it when you want to see the status (or debug) your script. <br>
    <br>
    screen -S foo<br>
    screen -r foo <br>
    /path/to/script.sh<br>
    CTRL-a d #detach from session<br>
    <br>
    Far easier than debugging log files!<br>
    <br>
    When I want to run a number of scripts or use cron to kick them off,
    I write a wrapper script which creates a screen session and injects
    the commands for example:<br>
    <br>
    screen -dm foo<br>
    sleep 5 #just gives the command time to execute<br>
    screen -X -S foo -p0 eval 'stuff /path/to/script.sh'<br>
    sleep 5<br>
    screen -X -S foo -p0 eval 'stuff \015' #return key equivalent<br>
    <br>
    Any screen can then be recovered to current terminal with <br>
    <br>
    screen -r foo #if the screen is currently not attached to any
    terminal<br>
    <br>
    or <br>
    <br>
    screen -x foo  #if it is already attached to a terminal<br>
    <br>
    to detach from the screen session use: <br>
    <br>
    CTRL-a d <br>
    <br>
    Alan<br>
    ================================<br>
    <br>
    On 21/11/12 16:26, David Halliday wrote:
    <blockquote
cite="mid:CALV+dNkcCRSLSpxNLu9B12WTtqCaxcnYE7K4Y4XHgBHOKLGDdA@mail.gmail.com"
      type="cite">
      <pre wrap="">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:
<a class="moz-txt-link-freetext" href="http://david-halliday.co.uk/wiki/doku.php?id=linux:bits:process_tree_with_ps">http://david-halliday.co.uk/wiki/doku.php?id=linux:bits:process_tree_with_ps</a>

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

</pre>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Kent mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a>
<a class="moz-txt-link-freetext" href="https://mailman.lug.org.uk/mailman/listinfo/kent">https://mailman.lug.org.uk/mailman/listinfo/kent</a></pre>
    </blockquote>
  </body>
</html>