Differences between “ & disown” and “nohup & disown”











up vote
30
down vote

favorite
12












This is my understanding about the usage of &, disown and nohup:





  • <command>: runs the process within the Terminal's current bash instance, in the foreground (i.e. the process is listed as a bash foreground job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> &: runs the process within the Terminal's current bash instance, in the background (i.e. the process is listed as a bash background job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are still bound to the terminal); immune to hangups;


  • nohup <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are not still bound to the terminal);immune to hangups;


So, aside from nohup <command> & disown blocking stdin and redirecting stdout and stderr to nohup.out by default, it seems to me like it can be considered totally equivalent to <command> & disown.



Is the above all correct? Any misconception?










share|improve this question




















  • 1




    What do you mean by "immune to hangups" and "not immune to hangups"?
    – chaos
    Apr 21 '15 at 9:36






  • 2




    @chaos I mean that terminating / killing the parent bash instance won't kill the process
    – kos
    Apr 21 '15 at 9:42















up vote
30
down vote

favorite
12












This is my understanding about the usage of &, disown and nohup:





  • <command>: runs the process within the Terminal's current bash instance, in the foreground (i.e. the process is listed as a bash foreground job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> &: runs the process within the Terminal's current bash instance, in the background (i.e. the process is listed as a bash background job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are still bound to the terminal); immune to hangups;


  • nohup <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are not still bound to the terminal);immune to hangups;


So, aside from nohup <command> & disown blocking stdin and redirecting stdout and stderr to nohup.out by default, it seems to me like it can be considered totally equivalent to <command> & disown.



Is the above all correct? Any misconception?










share|improve this question




















  • 1




    What do you mean by "immune to hangups" and "not immune to hangups"?
    – chaos
    Apr 21 '15 at 9:36






  • 2




    @chaos I mean that terminating / killing the parent bash instance won't kill the process
    – kos
    Apr 21 '15 at 9:42













up vote
30
down vote

favorite
12









up vote
30
down vote

favorite
12






12





This is my understanding about the usage of &, disown and nohup:





  • <command>: runs the process within the Terminal's current bash instance, in the foreground (i.e. the process is listed as a bash foreground job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> &: runs the process within the Terminal's current bash instance, in the background (i.e. the process is listed as a bash background job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are still bound to the terminal); immune to hangups;


  • nohup <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are not still bound to the terminal);immune to hangups;


So, aside from nohup <command> & disown blocking stdin and redirecting stdout and stderr to nohup.out by default, it seems to me like it can be considered totally equivalent to <command> & disown.



Is the above all correct? Any misconception?










share|improve this question















This is my understanding about the usage of &, disown and nohup:





  • <command>: runs the process within the Terminal's current bash instance, in the foreground (i.e. the process is listed as a bash foreground job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> &: runs the process within the Terminal's current bash instance, in the background (i.e. the process is listed as a bash background job and stdin, stdout and stderr are still bound to the terminal); not immune to hangups;


  • <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are still bound to the terminal); immune to hangups;


  • nohup <command> & disown: runs the process within the Terminal's current bash instance, in the background, but the process is detached from the bash's jobs' list (i.e. the process is not listed as a bash foreground / background job and stdin, stdout and stderr are not still bound to the terminal);immune to hangups;


So, aside from nohup <command> & disown blocking stdin and redirecting stdout and stderr to nohup.out by default, it seems to me like it can be considered totally equivalent to <command> & disown.



Is the above all correct? Any misconception?







command-line bash nohup background-process






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 21 '15 at 15:30

























asked Apr 21 '15 at 9:22









kos

25.2k869119




25.2k869119








  • 1




    What do you mean by "immune to hangups" and "not immune to hangups"?
    – chaos
    Apr 21 '15 at 9:36






  • 2




    @chaos I mean that terminating / killing the parent bash instance won't kill the process
    – kos
    Apr 21 '15 at 9:42














  • 1




    What do you mean by "immune to hangups" and "not immune to hangups"?
    – chaos
    Apr 21 '15 at 9:36






  • 2




    @chaos I mean that terminating / killing the parent bash instance won't kill the process
    – kos
    Apr 21 '15 at 9:42








1




1




What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36




What do you mean by "immune to hangups" and "not immune to hangups"?
– chaos
Apr 21 '15 at 9:36




2




2




@chaos I mean that terminating / killing the parent bash instance won't kill the process
– kos
Apr 21 '15 at 9:42




@chaos I mean that terminating / killing the parent bash instance won't kill the process
– kos
Apr 21 '15 at 9:42










2 Answers
2






active

oldest

votes

















up vote
22
down vote



accepted










Your understanding is basically correct. Both disown and nohup are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:




  • There's no reason to run nohup command & disown, nohup will already disown it for you.


  • nohup is defined by POSIX while disown is not. This means that while many shells (e.g. bash, zsh, ksh) have it, others (for example tcsh, csh, dash and sh) won't have it.


  • disown can be used after a command has been launched while nohup must be used before.



As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown and man nohup) but their basic function is the same, yes.



For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:




  • Do disown -h and nohup work effectively the same?

  • Difference between nohup, disown and &






share|improve this answer



















  • 11




    Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
    – memo
    Feb 10 '16 at 21:53




















up vote
7
down vote













Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal is not a right notion. stdin is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal is alright.



Your have stdin, stdout and stderr are not still bound to the terminal in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null as the input file to the command, for example if the command is cat, you are using it as cat /dev/null.



The command on your 5th point is not correctly put, you used nohup <command> & disown, while using any one of nohup or disown the other one is not needed. Their purposes are the same (to ignore the SIGHUP) but they function in a bit different way. So the command can be simplified as nohup <command> &.






share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f611968%2fdifferences-between-command-disown-and-nohup-command-disown%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    22
    down vote



    accepted










    Your understanding is basically correct. Both disown and nohup are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:




    • There's no reason to run nohup command & disown, nohup will already disown it for you.


    • nohup is defined by POSIX while disown is not. This means that while many shells (e.g. bash, zsh, ksh) have it, others (for example tcsh, csh, dash and sh) won't have it.


    • disown can be used after a command has been launched while nohup must be used before.



    As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown and man nohup) but their basic function is the same, yes.



    For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:




    • Do disown -h and nohup work effectively the same?

    • Difference between nohup, disown and &






    share|improve this answer



















    • 11




      Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
      – memo
      Feb 10 '16 at 21:53

















    up vote
    22
    down vote



    accepted










    Your understanding is basically correct. Both disown and nohup are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:




    • There's no reason to run nohup command & disown, nohup will already disown it for you.


    • nohup is defined by POSIX while disown is not. This means that while many shells (e.g. bash, zsh, ksh) have it, others (for example tcsh, csh, dash and sh) won't have it.


    • disown can be used after a command has been launched while nohup must be used before.



    As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown and man nohup) but their basic function is the same, yes.



    For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:




    • Do disown -h and nohup work effectively the same?

    • Difference between nohup, disown and &






    share|improve this answer



















    • 11




      Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
      – memo
      Feb 10 '16 at 21:53















    up vote
    22
    down vote



    accepted







    up vote
    22
    down vote



    accepted






    Your understanding is basically correct. Both disown and nohup are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:




    • There's no reason to run nohup command & disown, nohup will already disown it for you.


    • nohup is defined by POSIX while disown is not. This means that while many shells (e.g. bash, zsh, ksh) have it, others (for example tcsh, csh, dash and sh) won't have it.


    • disown can be used after a command has been launched while nohup must be used before.



    As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown and man nohup) but their basic function is the same, yes.



    For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:




    • Do disown -h and nohup work effectively the same?

    • Difference between nohup, disown and &






    share|improve this answer














    Your understanding is basically correct. Both disown and nohup are used to allow you to exit a running shell session without stopping running jobs. Some clarifications:




    • There's no reason to run nohup command & disown, nohup will already disown it for you.


    • nohup is defined by POSIX while disown is not. This means that while many shells (e.g. bash, zsh, ksh) have it, others (for example tcsh, csh, dash and sh) won't have it.


    • disown can be used after a command has been launched while nohup must be used before.



    As far as I can tell, the actual effect of the two commands is the same. They each have features that the other lacks (see help disown and man nohup) but their basic function is the same, yes.



    For a far more detailed discussion of these tools and the differences between them, have a look at the answers here:




    • Do disown -h and nohup work effectively the same?

    • Difference between nohup, disown and &







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 27 at 1:42

























    answered Apr 21 '15 at 15:51









    terdon

    63.8k12135212




    63.8k12135212








    • 11




      Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
      – memo
      Feb 10 '16 at 21:53
















    • 11




      Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
      – memo
      Feb 10 '16 at 21:53










    11




    11




    Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
    – memo
    Feb 10 '16 at 21:53






    Nohup and disown are not the same thing and using both commands together is NOT redundant. See this answer for an in depth description
    – memo
    Feb 10 '16 at 21:53














    up vote
    7
    down vote













    Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal is not a right notion. stdin is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal is alright.



    Your have stdin, stdout and stderr are not still bound to the terminal in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null as the input file to the command, for example if the command is cat, you are using it as cat /dev/null.



    The command on your 5th point is not correctly put, you used nohup <command> & disown, while using any one of nohup or disown the other one is not needed. Their purposes are the same (to ignore the SIGHUP) but they function in a bit different way. So the command can be simplified as nohup <command> &.






    share|improve this answer

























      up vote
      7
      down vote













      Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal is not a right notion. stdin is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal is alright.



      Your have stdin, stdout and stderr are not still bound to the terminal in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null as the input file to the command, for example if the command is cat, you are using it as cat /dev/null.



      The command on your 5th point is not correctly put, you used nohup <command> & disown, while using any one of nohup or disown the other one is not needed. Their purposes are the same (to ignore the SIGHUP) but they function in a bit different way. So the command can be simplified as nohup <command> &.






      share|improve this answer























        up vote
        7
        down vote










        up vote
        7
        down vote









        Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal is not a right notion. stdin is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal is alright.



        Your have stdin, stdout and stderr are not still bound to the terminal in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null as the input file to the command, for example if the command is cat, you are using it as cat /dev/null.



        The command on your 5th point is not correctly put, you used nohup <command> & disown, while using any one of nohup or disown the other one is not needed. Their purposes are the same (to ignore the SIGHUP) but they function in a bit different way. So the command can be simplified as nohup <command> &.






        share|improve this answer












        Your first to third points seem alright, although stdin, stdout and stderr are still bound to the terminal is not a right notion. stdin is always bound to terminal in the sense that you would always input the file name to a command via terminal or ways using terminal. stdout and stderr are still bound to the terminal is alright.



        Your have stdin, stdout and stderr are not still bound to the terminal in the fourth point which is not right as mentioned in my earlier paragraph. Also here you are using /dev/null as the input file to the command, for example if the command is cat, you are using it as cat /dev/null.



        The command on your 5th point is not correctly put, you used nohup <command> & disown, while using any one of nohup or disown the other one is not needed. Their purposes are the same (to ignore the SIGHUP) but they function in a bit different way. So the command can be simplified as nohup <command> &.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 21 '15 at 9:51









        heemayl

        65.6k8136210




        65.6k8136210






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f611968%2fdifferences-between-command-disown-and-nohup-command-disown%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?