$ type -a nohup
nohup is /usr/bin/nohup
Nohup is not part of the shell syntax. It is just an executable, which means you cannot just type arbitrary command and prefix it with
nohup to expect it to be executed with SIGHUP ignored. In the case of
nohup conda activate shuffle_pair_end_reads && python3 shuffle_pair_end_reads.py \
nohup is executed with the arguments
shuffle_pair_end_reads. Everything after the first
&& is another simple command.
nohup knows nothing about it and cannot control the behavior of it.
As it is written, it means executing
conda activate shuffle_pair_end_reads with
SIGHUP ignored, then if
nohup succeeds, process to the python script.
As for the redirection of stdin and stdout, the man page has stated clearly about it.
If standard input is a terminal, redirect it from /dev/null. If
standard output is a terminal, append output to 'nohup.out' if
possible, '$HOME/nohup.out' otherwise. If standard error is a
terminal, redirect it to standard output. To save output to FILE, use
'nohup COMMAND > FILE'.
In your case, the input of your command is not redirected, so
nohup redirects it for you from
nohup redirects the standard output to
nohup.out for you, issuing a warning (note this is just a warning) "ignoring input and appending output to 'nohup.out'" and writing the warning to stderr.
As for the exit status of
nohup, this question explains it well. You need to check by yourself why the command
nohup conda activate shuffle_end_reads is issuing an exit status of
nohup as though it were part of the
bash syntax can lead to funny errors. One of the simplest,
nohup cd myfolder && ./script.sh &
will fail with the following message written to stderr:
nohup: ignoring input and appending output to 'nohup.out'
nohup: failed to run command 'cd': No such file or directory
The first line is just a warning. The second line explains the error.
nohup just tries to invoke its
$1 as an executable and
cd is never a standalone executable.
When I need to combine multiple commands for
nohup, I usually use the syntax
nohup bash -c "long command" &
There may be better ways but that's what I use. In the example above, if there is really a reason that you cannot
nohup, I will do
nohup bash -c "cd myfolder && ./script.sh` &
One last thing to keep in mind is that your program may install its own signal handlers that makes
nohup useless. As shown in this question.