The script is:
Nohup/mnt/nand3/h2000g>/dev/null 2> & 1 &
For & 1, it should be file descriptor 1, while 1 generally represents stdout_fileno. In fact, this operation is a dup2 (2) Call. it outputs the standard output to all_result, and then copies the standard output to file descriptor 2 (stderr_fileno). The consequence is that file descriptors 1 and 2 point to the same file table item, it can also be said that the wrong output is merged. 0 indicates keyboard input 1 indicates screen output 2 indicates wrong output. redirects a standard error to the standard output and then throws it to/dev/null. In layman's terms, all the standard output and standard errors are thrown into the waste bin.
Command> out. File 2> & 1 &
Command> out. File redirects the command output to the out. File file. That is, the output content is not printed to the screen, but output to the out. File file. 2> & 1 redirects a standard error to the standard output. The standard output has been redirected to the out. File file, which outputs a standard error to the out. File file. The last & is to run the command in the background.
Imagine what 2> 1 represents, 2 and> combined represents error redirection, and 1 represents an error redirected to a file 1, not a standard output;
Switch to 2> & 1, & combined with 1 indicates the standard output, and the error is redirected to the standard output.
You can use
Ls 2> 1 test. The system does not report the error of NO 2 files, but outputs an empty file 1;
Ls XXX 2> 1 test, no errors in the xxx file are output to 1;
Ls XXX 2> & 1 test. The file 1 is not generated, but the error is returned to the standard output;
Ls XXX> out.txt 2> & 1, which can be changed to LS xxx 1> out.txt 2> & 1; the redirection symbol> timeout is a error and the output is transmitted to out.txt.
Why 2> & 1 should be written at the end?
Command> file 2> & 1
First, the command> file redirects the standard output to the file. 2> & 1 indicates that the standard output is copied due to a standard error, that is, it is also redirected to the file, the final result is that both the standard output and errors are redirected to the file.
Command 2> & 1> File
2> & 1 the standard error copies the standard output, but the standard output is still on the terminal.> The output is redirected to the file, but the standard error is still on the terminal.
Use strace to see:
1. Command> file 2> & 1
The key System Call Sequence for implementing redirection in this command is:
Open (File) = 3
Dup2 (3, 1)
Dup2 (1, 2)
2. Command 2> & 1> File
The key System Call Sequence for implementing redirection in this command is:
Dup2 (1, 2)
Open (File) = 3
Dup2 (3, 1)
Consider the file sharing structure generated by different dup2 () call sequences. See apue 3.10, 3.12