009-Linux nohup

A basic overview

1、/dev/null

  / Dev / null can be seen as a "black hole." It is very equivalent to a write-only file. It's all written content will be lost forever. And try to read from it there did not read. But then, / dev / null are very useful command line and scripts. 

  Use: 
    ban the standard output 1 cat $ filename> / dev / null # contents of the file is lost, but not to the standard output. 
    Prohibition standard error 2> / dev / null so the error message [standard error] is discarded.

2,> and >>, <, & binding equivalent to

  Linux shell there are three input and output are standard input, standard output, error output, corresponding 0,1,2. The default value is 1, we can directly output redirection> (or >> indicates additional) to redirect the output to some other places, such as equipment, file

  > Number greater than: a command execution result (standard output, or error output, would be printed to the screen above) redirect other output devices (file, the operator opens the file, or printer, etc.)

  <Less: default input command obtained from the keyboard, from a file change, or other input device, and open the file: Command <File "which is input as a command file

  >> is additional content

  > Overwriting existing content, where representatives redirected to

    echo "aaa"> log.txt meaning: the aaa write log.txt

    echo "bbb" >> log.txt meaning: bbb added to log.txt

    > Log.txt meaning: Empty rewritten to be written

    :> Log.txt meaning: Empty rewrite

    ls > ls.log  #标准输出重定向 到ls.log

    ls 2> ls.log #标准错误重定向 到ls.log

    ls > /dev/null #重定向到null设备,相当于直接忽略输出

  Example: 1> / dev / null Meaning 2> & 1

 

    1 represents a standard output stdout, the system default value is 1, the "> / dev / null" is equivalent to "1> / dev / null" 

    2 represents standard error stderr 

    Represents & meaning equivalent to, 2> & 1, 2 indicates an output equivalent to a redirection 

  meaning:

    1> / dev / null first standard output redirection device to an empty file, i.e. does not output any information to the terminal, it means no information is displayed. 

    2> & 1 Next, the standard output redirection is equivalent to the standard error output, the standard output because before the empty device has been redirected to the file, it can redirect the standard error output device to an empty file.

3, Command & 

  & In the command represents the set back this process as a background process

  By default, the process is the foreground process, then this process (equivalent to command nature is to open a process) to occupy Shell put, we can not carry out other operations, for those processes that do not interact very often, we want to it started in the background, you can add a parameter at startup '&' for this purpose.

  grammar:command &

4、nohup

  Do not hang up the run command. Abbreviations no hangup, which means "do not hang up." Ignore all hang (SIGHUP) signals

  Syntax: nohup Command [Arg ...] [&]

  nohup runs a command specified by the Command parameter and any related Arg parameters of command, ignore all hang (SIGHUP) signals. The program runs in the background using nohup command after logout. To run a background in nohup command, add & (representation "and" sign) to the end of the command. If you do not redirect the output, the output will be appended to the command nohup nohup.out files in the current directory. If nohup.out not write files in the current directory, output is redirected to $ HOME / nohup.out file.

 

命令:nohup echo  </dev/null &>>start.log &

  说明:nohup 【echo  </dev/null &>>start.log】 &

  echo </ dev / null & Meaning: / dev / null input to the echo as a background process,

  >> start.log appended to the file start.log

  

  

 

 

 

 

 

 

 

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/bjlhx/p/11126822.html