I have used screen for running scripts, many of us on the team use it as a matter of course. I remember discovering screen and deciding that sliced bread had nothing on it!<br><br>I hadn't seen this method of running scripts within a screen session before, very interesting. Although it doesn't give me the immediate snapshot on all running scripts that my bash functions do (which was part of the original aim).<br>
<div class="gmail_extra"><br><br><div class="gmail_quote">On 21 November 2012 19:42, Alan Buchel <span dir="ltr"><<a href="mailto:alan@communitytechnology.org.uk" target="_blank">alan@communitytechnology.org.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div 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>
================================<div><div class="h5"><br>
<br>
On 21/11/12 16:26, David Halliday wrote:
</div></div><blockquote type="cite"><div><div class="h5">
<pre>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 href="http://david-halliday.co.uk/wiki/doku.php?id=linux:bits:process_tree_with_ps" target="_blank">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>
</div></div><pre><fieldset></fieldset>
_______________________________________________
Kent mailing list
<a href="mailto:Kent@mailman.lug.org.uk" target="_blank">Kent@mailman.lug.org.uk</a>
<a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a></pre>
</blockquote>
</div>
<br>_______________________________________________<br>
Kent mailing list<br>
<a href="mailto:Kent@mailman.lug.org.uk">Kent@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/kent" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/kent</a><br></blockquote></div><br></div>