linux resolves an issue where background processes will automatically exit

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.