5
2
I use nohup
quite often for important long running processes under linux
/bash
, so much so that nohup time my command with arguments && mv nohup.out my.log
is almost an idiom for me.
The problem is that nohup
puts both stdout
and stderr
into nohup.out
, and I cannot control the name of the file. This means that if I accidentally start two nohup
s in the same directory, their output will be interleaved in nohup.out
.
The questions are:
How do I deal with this problem? Always running
nohup
s in separate directories and writing a shell function which will first check for./nohup.out
are two sucky options I see.How come I cannot tell
nohup
where to redirect the output? GNU tools tend to have so many options, why notnohup
?
GNU nohup says that it'll redirect stdout to a file if you specify
nohup command > file
Isn't redirection in case ofnohup command > file
being handled by shell and notnohup
? If so then how cannohup
take any action based on weather redirection is present or not? – Piotr Dobrogost – 2015-01-21T08:29:00.570The file
nohup.out
will be created in the case of error output, too; but if you redirect both stdout and stderr, there cannot be any output, so the file will not be created. But the&>
syntax is not POSIX-compliant; you're better off with the answer by Irshad Khan elsewhere on this page. – tripleee – 2018-04-20T07:14:23.930Will it prevent
nohup
from performing its own redirection? – user1686 – 2013-02-14T15:45:32.7901GNU
nohup
says that it'll redirect stdout to a file if you specifynohup command > file
. BSDnohup
doesn't mention this at all, but it worked for me. – slhck – 2013-02-14T15:50:10.467