The original link is: http://blog.sina.com.cn/s/blog_963453200102uya7.html
& placed after the startup parameter to set this process as a background process
By default, the process is the foreground process, then the shell is occupied, we can not do other operations, for those who do not interact with the process, many times, we want to start in the background, you can start the parameters with a ' & ' to achieve this purpose.
Such as:
Tianfang > Run &
[1]11319
Tianfang >/GAME.E 1 &
When the process switches to the background, we call it job. When switching to the background, the relevant job information is output, with the preceding output as [1]11319 Example: [1] indicating that Jobid is 1,11319 that the process ID is 11319. A process that switches to the background can still be viewed with the PS command.
Switching between front and rear tables
The BG (background) and FG (foreground) commands allow them to switch between the pre-background state.
Daemon process
If a process is always started in the background and cannot be exited by a shell exit, it is a legitimate practice to create it as a daemon. The daemon is worth the long-running background process of the system, similar to Windows services. Daemon information through Ps–a can not see, need to use the –x parameter, when using this command, often also attach-j parameters to view job control information, where Tpgid column is 1 is the daemon process.
tianfang> PS XJ
PPID PID pgid SID TTY tpgid STAT UID time COMMAND
953 1190 1190 1190? -1 Ss-0:00/bin/sh/usr/bin/startkde
1 1490 1482 1482? -1 Sl 0:00/usr/bin/vboxclient–seamless
1 1491 1477 1477? -1 Sl 0:00/usr/bin/vboxclient–display
The most critical step in creating a daemon is to call the SETSID function to create a new session and become a sessionleader. The result of a successful call to this function is:
- Create a new session, the current process becomes sessionleader, the ID of the current process is the session ID
- Create a new process group, the current process becomes the leader of the process group, and the ID of the current process is the ID of the process group
- If the current process originally had a control terminal, it would lose the control terminal and become a process without the control terminal.
Function of the character ' & ' after running the command in the Linux Shell (go)