nohup sh start.sh >/dev/null 2>&1 &

nohup sh start.sh >/dev/null 2>&1 &


 

Background note

start.sh script, write the commands for the Java application launcher, and configure the output path of the log in the log4j.properties.

At this point, start the service, if you use the following command will be in the directory where the script start.sh generate a file named nohup.out output file.

nohup sh start.sh &

 

The excess nohup.out file is not needed, use the following command to solve:

nohup sh start.sh >/dev/null 2>&1 &

 

Command parsing

1、nohup &

nohup represent permanent operation , & represents the background .

 

2、>/dev/null 2>&1

/ dev / null Representative empty file device , i.e. does not output any information to the terminal.

There are three commonly used operating system flow:
  0: standard input stream stdin
  . 1: standard output stream stdout
  2: standard error stream stderr

" > / Dev / null " is equivalent to " 1> / dev / null ", indicates the standard output (1) to  / dev / null  , i.e. the terminal does not output the standard output ;

" 2> & 1 " in the " & " is equivalent to mean, represents a standard error (2) output from the position equivalent to the standard output (1) position, i.e., equivalent to " 2> / dev / null ", i.e., the terminal does not output the standard error .

Thus, " > / dev / null 2> &. 1 " represents the standard output and standard error message information, not on the output terminal.


 

3, specify the output file

If you want to process the output log information service up and running to a specified location (for example: /var/log/start.log ), you can refer to the following command:

nohup sh start.sh >/var/log/start.log 2>&1 &

 

Guess you like

Origin www.cnblogs.com/miracle-luna/p/11802630.html