From: Darren Kenny (Darren.Kenny at domain Sun.COM)
Date: Mon 22 Oct 2001 - 13:22:03 IST
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 domain linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at domain linux.ie
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:12:51 GMT