Problem:
Before executing the MV command, often will automatically exit, both sides have space, and there is no movement to complete, this is because in the background execution, actually put him in the queue to execute, when the parent process dies, the default will give the child process a signal, the child process will automatically kill. Later, the following three methods were used to solve the problem
Method One:
[Email protected] ~]# nohup MV adduser.py.
Nohup: Ignore input and append output to "Nohup.out"
[[email protected] ~]# cat nohup.out//This time the view is not content, he will put the standard output to the current directory
This file can play a role in a log.
Method Two:
[Email protected] ~]# setsid MV adduser.py.
After the Setsid () call succeeds, the ID of the new session is returned, the process that calls the SETSID function becomes the lead process for the new session, and is detached from the session group and Process Group of its parent process. Because the session is exclusive to the control terminal, the process is detached from the control terminal, before the parent and child run in the same session, and the parent is the lead process of the conversation.
The parent process acts as the lead process for the session, and if exit is executed, the child process becomes the orphan process and is adopted by INIT.
After executing setsid (), child will regain a new session ID.
After the parent exits, the child will not be affected.
Method Three:
[Email protected] ~]# (MV Test.txt..) &
This is to put the process into a subshell, and Setsid have the same second
In fact, there are many methods, here only three kinds of records!!!
This article is from the "Court of the Odd Tree" blog, please be sure to keep this source http://zhangdl.blog.51cto.com/11050780/1834679
linux resolves an issue where background processes will automatically exit