Shell : bash
OS : Oracle Linux 6.4
I want to save the ouput of a nohup command to file other than nohup.out . Below are my 3 attempts.
For both Attempt1 and Attempt2 , the redirection logs the output correctly to the output file. But I get the error "ignoring input and redirecting stderr to stdout" in the shell just after the nohup command is issued.
I tried Attempt3 with 2>&1. This one also logged to output file. This time I didn't get the error "ignoring input and redirecting stderr to stdout" . But I got "nohup: ignoring input" as the first line in the error log.
How can I get an error-less redirection of nohup output file ?
I am creating a formal document detailing steps for a critical activity. Althoug the below executions work fine , I want to get rid of those ignorable errors. Any idea how I can get rid of those errors ?
$ cat test.sh
#!/bin/bash
echo -e "hello world Start"
sleep 10
echo -e "hello world End"
mumbojumbo
$
## Attempt1.
$
$ nohup test.sh >MyOutput.log &
[1] 6535
$ nohup: ignoring input and redirecting stderr to stdout
$
$ cat MyOutput.log
hello world Start
hello world End
./test.sh: line 5: mumbojumbo: command not found
[1]+ Exit 127 nohup test.sh > MyOutput.log
### Attemp2 (a space after the redirection character > )
$ nohup test.sh > MyOutput.log &
[1] 9914
$ nohup: ignoring input and redirecting stderr to stdout
$
$ cat MyOutput.log
hello world Start
hello world End
./test.sh: line 5: mumbojumbo: command not found
[1]+ Exit 127 nohup test.sh > MyOutput.log
Attempt3. using 2>&1
$ nohup test.sh > MyOutput.log 2>&1 &
[1] 11773
$
$
$
$
$ cat MyOutput.log
nohup: ignoring input
hello world Start
hello world End
./test.sh: line 5: mumbojumbo: command not found