macports with closed stdout

Eric A. Borisch eborisch at macports.org
Tue May 5 11:44:42 PDT 2015


On Tue, May 5, 2015 at 1:23 PM, René J.V. <rjvbertin at gmail.com> wrote:

> On Tuesday May 05 2015 19:58:44 Clemens Lang wrote:
> >That sounds like a perfect use case for screen or tmux.
>
> I might check out tmux, but screen gets in my way by trying to be too
> clever. The easiest would be to redirect all output (">&") to file and then
> use tail -f until I decide to disconnect. Or maybe it'll be enough to pipe
> all output to cat, or otherwise an application that redirects it output
> elsewhere if stdout/stderr are closed (I think I must have something like
> that lying around). More often than not all that interests me when
> reconnecting is if the port command completed successfully, because if not
> there are logs already.


Here's the (bash) you're looking for:

nohup [your command here] &> outputs.log < /dev/null &

You can happily tail -f outputs.log, or close the ssh session, or have the
connection drop, without "hanging up" on the command. Starts in the
background so you don't even have to do that. Obviously of no use for
interactive tools (stdin redirected from /dev/null.)

You could even create a bash function that wraps all this (nohup invocation
& log tail-ing) for you.

 - Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-dev/attachments/20150505/14e464f1/attachment.html>


More information about the macports-dev mailing list