Use the nohup commandProgramAlways run in the background
Http://linux.chinaunix.net/techdoc/system/2009/09/01/1133290.shtml
In Unix/Linux, you generally want to run a program in the background. Many of them use & at the end of the program to run the program automatically. For example, to run MySql in the background:
/Usr/local/MySQL/bin/mysqld_safe -- user = MySQL &
However, many of our programs do not support daemon like mysqld. Maybe our program is just a common program. Generally, even if this program is used and ended, if the terminal is closed, the program will also be closed. To be able to run in the background, we need to use the nohup command. For example, if we have a start. Sh command that needs to run in the background and want to run it all the time in the background, we should use nohup:
Nohup/root/start. Sh &
After you press enter in shell, the following message is displayed:
[~] $ Appending output to nohup. Out
The standard output of the original program is automatically redirected to the nohup. Out file in the current directory, which plays the role of log.
But sometimes there is a problem at this step. When the terminal is closed, the process will be automatically closed. Check nohup. Out to see that the service will be automatically closed when the terminal is closed.
After consulting with the red-flag Linux engineer, he could not solve the problem. After executing the command on my terminal, the process he started was still running after the terminal was closed. During the second demonstration to me, I found that I had a different detail with him when operating the terminal: when the shell prompts that nohup is successful, you also need to press any key on the terminal to return to the shell input command window, and then enter exit in the shell to exit the terminal; however, I click the close program button to close the terminal every time the nohup operation is successful .. Therefore, the session corresponding to the command will be disconnected at this time, and the process corresponding to nohup will be notified and shutdown will be required together.