LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] tee problem

[ILUG] tee problem

Darren Kenny Darren.Kenny at Sun.COM
Mon Oct 22 13:22:03 IST 2001


The best way to achieve what you want would be to do something like:

	nohup $COMMAND > ${LOG_DIR}/${LOG_FILE} 2>&1 &
	tail +0f ${LOG_DIR}/${LOG_FILE} &
	TAIL_PID=$!

	trap 'kill ${TAIL_PID} 2>/dev/null' 0 1 2 15

This should put the process in the background, logging output
to a file, and then 'tail' the file, also in the background, with
output to the screen. The PID of the tail is remembered, and the trap
will cause the tail to be killed on the exit of SCRIPT A (just
to clean up) - I'm assuming that you don't want the output after SCRIPT A
has exited...

Hope this helps,

Darren.

Justin Mason wrote:
> 
> "Richard O'Mahony" said:
> 
> > The problem is that the script hangs at this line. the problem is due t
> > o the fact the the $COMMAND script creates a deamon process during its
> > execution and the tee command will not exit until $COMMANAND and all of
> > its child processes have also stopped. What I am looking for is
> > alternative to tee (to log results to a file as well as printing them on
> > the screen)or some way to force the completion of the command. Using '&'
> > to put the command into the background is not acceptable as SCRIPT A
> > interacts with the user.
> 
> "nohup" is what you want, I think.  Run the daemon with nohup (and lose
> its output, unfortunately).
> 
> Alternatively, fix it so the daemon logs into a file, then use "tail -f"
> in script A to read its output interactively.
> 
> --j.
> 
> --
> Irish Linux Users' Group: ilug at linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell