nohup output redirection to a different file
You can redirect both stdout and stderr to one file. With Bash 4 (or others such as Zsh), as easy as:
nohup <some-command> &> output.log
I can't tell you why there's no separate option for nohup
to set the output, but if your shell can take care of that, you don't really need an option.
To Append output in user defined file you can use >>
in nohup command.
nohup php your_command >> filename.out 2>&1 &
This command will append all output in your file without removing old data.
There are more ways than just nohup
to start a process so that it would ignore SIGHUP; for example: (written as shell functions)
nohup() {
setsid "$@"
}
nohup() {
("$@" &)
}
nohup() {
"$@" & disown
}
(setsid
, or even (setsid "$@" &)
, might be the best choice.)
All of them allow you to specify your own redirections with >
, 2>
, and &>
/>&
.