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

1. Purpose: nohup means permanent operation. & Means running in the background

When using Unix/Linux, we generally want a program to run in the background, nohup ./start-mysql.sh &

The general form of this command is: nohup command &

By default, all output of the job is redirected to a file named nohup.out, unless otherwise specified output file:

nohup command > myout.file 2>&1 &

In the above example, the output is redirected to the myout.file file.

二、>/dev/null 2>&1

/dev/null represents an empty device file, that is, no information is output to the terminal. To put it bluntly, no information is displayed.
> Means where to redirect to
1 means stdout standard output, the system default value is 1, so ">/dev/null" is equivalent to "1>/dev/null"
2 means stderr standard error
& means equivalent, 2> &1, which means that the output redirection of 2 is equivalent to 1
nohup ./mqnamesrv >/home/cxb/mqnamesrv.out 2>&1 & 
is the standard output to mqnamesrv.out, and then the standard error output redirection is equivalent to standard output, output To the same file.

3. Use jobs to view tasks.

Use fg %n to close.

Fourth, the difference between sh xxx.sh and ./xxx.sh

sh xxx.sh is used to execute start.sh with sh. Start.sh does not need to have an execution flag. You don’t need to add ./, you don’t need to write #!/bin/sh on the first line of the script./start.sh is the first line of the
script to call One-line shell to explain and execute, the default is sh, which is bash

Guess you like

Origin blog.csdn.net/My_SweetXue/article/details/110435431