Linux runs a process directly, after the current command ends, or closes the shell window, the process will end.
How to run a process in the background
Method 1
Using the nohup command, the nohup command itself means no hung up means that the shell will not be closed, closed. Drop the process.
Use nohup command & make the command run in the background, you can see the background running through job -l.
The place where the pit is compared is that if the shell is closed directly, the shell will also close the background command. To exit the shell, you need to run the command first and then close it to run in the background.
Method 2
Run in the background with a script, for example, I want to run mongod --dbpath="abc" to start mongodb.
First write a script test.sh, the content can be
#!/bin/sh
mongod --dbpath="abc"start mongodb &< Br>
#这& is important, otherwise you cannot exit the current command.
Then run test.sh directly. At this time mongodb has started and run the shutdown shell will not stop, the problem is coming, why is this, some people on the network explained that
running with test.sh will end immediately, mongodb is indicated by the & Run in the background, the parent process running test.sh is the current shell, (view the shell process number can be viewed by echo $$), test.sh runs over, but mongod will not run, test.sh will be very responsible Mongod is hosted to the system init process via ps -ef|
Grep mongod can see that mongod's parent process is 1.
Method 3
Set mongod's parent process directly to init process via setsid
setsid mongod --dbpath="abc"Start mongodb, check the mongod process and find it The parent process is 1.
References: http://www.cnblogs.com/lwm-1988/archive/2011/08/20/2147299.html
minicom is very easy to use, but sometimes not intuitive enough, it is recommended that newcomers, e
How to install JDK graphic parsing in Ubuntu, for many friends who dont know how to operate,
Understand the process: ? PID, PPID? Current process status? Memory allocation? CPU and actu
in CentOS Introduction to lvs LVS has a similar point to other application-layer or IP-based load b
How to run the process in Linux
Linux multi-command sequential execution
8 tips make you a superb Linux end user
How to add fonts in Linux system
Solve linux64 bit installation jpeg error make:./libtool:Commandnotfound
How to configure Chinese input method in Linux environment
Linux installer and common methods of relying on the installation package
Ubuntu Linux environment variable PATH setting
Basic instructions for use under Linux and configuration of makefile
How to delete recent documents without displaying recent documents (1)
How to use IE11 browser to protect privacy and security under Win8 system
What should I do if the Win7 system wireless signal is weak?
6 different ways to use the mouse wheel under Win7 system
How to install offline in win10 preview. .net framework 3.5
Win10 first anniversary 14393.10 cumulative update KB3176929 pushes
Five Keys to Hardening Host Security
Win10 boot press F8 can not enter the safe mode how to do?
Ballmer Peking University Speech: Five Technology Trends Guide Win8 Development