Proper way to start a background processWhy does “su -c <command> &” seemingly allow a command...

Can you feel passing through the sound barrier in an F-16?

What magic extends life or grants immortality?

Why did this happen to Thanos's ships at the end of "Avengers: Endgame"?

Fried gnocchi with spinach, bacon, cream sauce in a single pan

Can pay be witheld for hours cleaning up after closing time?

Was Tuvok bluffing when he said that Voyager's transporters rendered the Kazon weapons useless?

Are illustrations in novels frowned upon?

Why is observed clock rate < 3MHz on Arduino Uno?

Justifying the use of directed energy weapons

If I have a 16.67% fail rate (N=24) & I do another 24 tests, what is the likelihood that I get 0 fails by chance?

Why does The Ancient One think differently about Doctor Strange in Endgame than the film Doctor Strange?

The teacher logged me in as administrator for doing a short task, is the whole system now compromised?

How to compare two different formulations of a problem?

How to persuade recruiters to send me the Job Description?

In what ways can a Non-paladin access Paladin spells?

How do I make distance between concentric circles equal?

Sleeping solo in a double sleeping bag

LeetCode: Pascal's Triangle C#

What’s the difference between something that approaches infinity and something that is infinite.

Can you help me understand Modes from the aspect of chord changes?

Why don't we use Cavea-B

Is a butterfly one or two animals?

Gamma GLM - Derive prediction intervals for new x_i

Which household object drew this pattern?



Proper way to start a background process


Why does “su -c <command> &” seemingly allow a command to run in the background without hanging upHow do I execute in background / return early?Why does my Python background process end when SSH session is terminated?How to interrupt uninterruptible program?Exiting terminal running “nohup ./my_script &” => “You have running jobs”. OK to exit?ssh does not return when executing remote process in bgWhen tmux exits (closes pty master), background processes from startup scripts die — why?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I am just trying to start up a basic node.js server on a remote machine in a ssh session. This seems to work:



nohup node server/server.js &  disown


Maybe I don't need nohup? what's the "official" way to startup a background process that's not going to get killed by SIGTERM etc? I just want to start a background process then exit the session and have the process continue to run.










share|improve this question






















  • 1





    Neither nohup nor disown will do anything related to the TERM signal, only the HUP signal (nohup makes it ignore it and disown stops the shell form sending it, so using both is not needed). Could you expand on the "etc." at the end?

    – Kusalananda
    2 days ago













  • sure, I just want to start a background process then exit the session and have the process continue to run

    – Alexander Mills
    2 days ago






  • 1





    Have you considered using either tmux or GNU screen?

    – Kusalananda
    2 days ago






  • 5





    ... or creating a proper system service?

    – Jeff Schaller
    2 days ago











  • isn't a proper system service just using these types of facilities under the hood? can you add an answer showing one or the other?

    – Alexander Mills
    yesterday


















0















I am just trying to start up a basic node.js server on a remote machine in a ssh session. This seems to work:



nohup node server/server.js &  disown


Maybe I don't need nohup? what's the "official" way to startup a background process that's not going to get killed by SIGTERM etc? I just want to start a background process then exit the session and have the process continue to run.










share|improve this question






















  • 1





    Neither nohup nor disown will do anything related to the TERM signal, only the HUP signal (nohup makes it ignore it and disown stops the shell form sending it, so using both is not needed). Could you expand on the "etc." at the end?

    – Kusalananda
    2 days ago













  • sure, I just want to start a background process then exit the session and have the process continue to run

    – Alexander Mills
    2 days ago






  • 1





    Have you considered using either tmux or GNU screen?

    – Kusalananda
    2 days ago






  • 5





    ... or creating a proper system service?

    – Jeff Schaller
    2 days ago











  • isn't a proper system service just using these types of facilities under the hood? can you add an answer showing one or the other?

    – Alexander Mills
    yesterday














0












0








0








I am just trying to start up a basic node.js server on a remote machine in a ssh session. This seems to work:



nohup node server/server.js &  disown


Maybe I don't need nohup? what's the "official" way to startup a background process that's not going to get killed by SIGTERM etc? I just want to start a background process then exit the session and have the process continue to run.










share|improve this question
















I am just trying to start up a basic node.js server on a remote machine in a ssh session. This seems to work:



nohup node server/server.js &  disown


Maybe I don't need nohup? what's the "official" way to startup a background process that's not going to get killed by SIGTERM etc? I just want to start a background process then exit the session and have the process continue to run.







background-process daemon disown






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







Alexander Mills

















asked 2 days ago









Alexander MillsAlexander Mills

2,4972 gold badges22 silver badges70 bronze badges




2,4972 gold badges22 silver badges70 bronze badges











  • 1





    Neither nohup nor disown will do anything related to the TERM signal, only the HUP signal (nohup makes it ignore it and disown stops the shell form sending it, so using both is not needed). Could you expand on the "etc." at the end?

    – Kusalananda
    2 days ago













  • sure, I just want to start a background process then exit the session and have the process continue to run

    – Alexander Mills
    2 days ago






  • 1





    Have you considered using either tmux or GNU screen?

    – Kusalananda
    2 days ago






  • 5





    ... or creating a proper system service?

    – Jeff Schaller
    2 days ago











  • isn't a proper system service just using these types of facilities under the hood? can you add an answer showing one or the other?

    – Alexander Mills
    yesterday














  • 1





    Neither nohup nor disown will do anything related to the TERM signal, only the HUP signal (nohup makes it ignore it and disown stops the shell form sending it, so using both is not needed). Could you expand on the "etc." at the end?

    – Kusalananda
    2 days ago













  • sure, I just want to start a background process then exit the session and have the process continue to run

    – Alexander Mills
    2 days ago






  • 1





    Have you considered using either tmux or GNU screen?

    – Kusalananda
    2 days ago






  • 5





    ... or creating a proper system service?

    – Jeff Schaller
    2 days ago











  • isn't a proper system service just using these types of facilities under the hood? can you add an answer showing one or the other?

    – Alexander Mills
    yesterday








1




1





Neither nohup nor disown will do anything related to the TERM signal, only the HUP signal (nohup makes it ignore it and disown stops the shell form sending it, so using both is not needed). Could you expand on the "etc." at the end?

– Kusalananda
2 days ago







Neither nohup nor disown will do anything related to the TERM signal, only the HUP signal (nohup makes it ignore it and disown stops the shell form sending it, so using both is not needed). Could you expand on the "etc." at the end?

– Kusalananda
2 days ago















sure, I just want to start a background process then exit the session and have the process continue to run

– Alexander Mills
2 days ago





sure, I just want to start a background process then exit the session and have the process continue to run

– Alexander Mills
2 days ago




1




1





Have you considered using either tmux or GNU screen?

– Kusalananda
2 days ago





Have you considered using either tmux or GNU screen?

– Kusalananda
2 days ago




5




5





... or creating a proper system service?

– Jeff Schaller
2 days ago





... or creating a proper system service?

– Jeff Schaller
2 days ago













isn't a proper system service just using these types of facilities under the hood? can you add an answer showing one or the other?

– Alexander Mills
yesterday





isn't a proper system service just using these types of facilities under the hood? can you add an answer showing one or the other?

– Alexander Mills
yesterday










1 Answer
1






active

oldest

votes


















1













You can use the screen command to save terminal sessions that can be accessed at a later time. This keeps you from having to kill processes that may be attached to a terminal session. So one example of how this is useful is if you were going to start a huge data transfer. You can start a screen session, start transferring the data, go home and ssh back into your work machine, and access the screen session without the transfer being interrupted



To install it:



sudo apt install screen for Ubuntu or Ubuntu variant



yum install screen Redhat or Redhat variant



you can then run



screen -S <screen name> to create new screen session



screen -ls list screen sessions



screen -r <screen name> attach to specific screen.



tmux is slowly replacing the screen command so I would recommend looking into that as well.






share|improve this answer




























  • yes I hear tmux can also be used for this, is that the best option?

    – Alexander Mills
    2 days ago






  • 1





    Yeah, I would just go with learning tmux. @AlexanderMills

    – Gordster
    yesterday














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f536340%2fproper-way-to-start-a-background-process%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1













You can use the screen command to save terminal sessions that can be accessed at a later time. This keeps you from having to kill processes that may be attached to a terminal session. So one example of how this is useful is if you were going to start a huge data transfer. You can start a screen session, start transferring the data, go home and ssh back into your work machine, and access the screen session without the transfer being interrupted



To install it:



sudo apt install screen for Ubuntu or Ubuntu variant



yum install screen Redhat or Redhat variant



you can then run



screen -S <screen name> to create new screen session



screen -ls list screen sessions



screen -r <screen name> attach to specific screen.



tmux is slowly replacing the screen command so I would recommend looking into that as well.






share|improve this answer




























  • yes I hear tmux can also be used for this, is that the best option?

    – Alexander Mills
    2 days ago






  • 1





    Yeah, I would just go with learning tmux. @AlexanderMills

    – Gordster
    yesterday
















1













You can use the screen command to save terminal sessions that can be accessed at a later time. This keeps you from having to kill processes that may be attached to a terminal session. So one example of how this is useful is if you were going to start a huge data transfer. You can start a screen session, start transferring the data, go home and ssh back into your work machine, and access the screen session without the transfer being interrupted



To install it:



sudo apt install screen for Ubuntu or Ubuntu variant



yum install screen Redhat or Redhat variant



you can then run



screen -S <screen name> to create new screen session



screen -ls list screen sessions



screen -r <screen name> attach to specific screen.



tmux is slowly replacing the screen command so I would recommend looking into that as well.






share|improve this answer




























  • yes I hear tmux can also be used for this, is that the best option?

    – Alexander Mills
    2 days ago






  • 1





    Yeah, I would just go with learning tmux. @AlexanderMills

    – Gordster
    yesterday














1












1








1







You can use the screen command to save terminal sessions that can be accessed at a later time. This keeps you from having to kill processes that may be attached to a terminal session. So one example of how this is useful is if you were going to start a huge data transfer. You can start a screen session, start transferring the data, go home and ssh back into your work machine, and access the screen session without the transfer being interrupted



To install it:



sudo apt install screen for Ubuntu or Ubuntu variant



yum install screen Redhat or Redhat variant



you can then run



screen -S <screen name> to create new screen session



screen -ls list screen sessions



screen -r <screen name> attach to specific screen.



tmux is slowly replacing the screen command so I would recommend looking into that as well.






share|improve this answer















You can use the screen command to save terminal sessions that can be accessed at a later time. This keeps you from having to kill processes that may be attached to a terminal session. So one example of how this is useful is if you were going to start a huge data transfer. You can start a screen session, start transferring the data, go home and ssh back into your work machine, and access the screen session without the transfer being interrupted



To install it:



sudo apt install screen for Ubuntu or Ubuntu variant



yum install screen Redhat or Redhat variant



you can then run



screen -S <screen name> to create new screen session



screen -ls list screen sessions



screen -r <screen name> attach to specific screen.



tmux is slowly replacing the screen command so I would recommend looking into that as well.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









GordsterGordster

2061 silver badge6 bronze badges




2061 silver badge6 bronze badges
















  • yes I hear tmux can also be used for this, is that the best option?

    – Alexander Mills
    2 days ago






  • 1





    Yeah, I would just go with learning tmux. @AlexanderMills

    – Gordster
    yesterday



















  • yes I hear tmux can also be used for this, is that the best option?

    – Alexander Mills
    2 days ago






  • 1





    Yeah, I would just go with learning tmux. @AlexanderMills

    – Gordster
    yesterday

















yes I hear tmux can also be used for this, is that the best option?

– Alexander Mills
2 days ago





yes I hear tmux can also be used for this, is that the best option?

– Alexander Mills
2 days ago




1




1





Yeah, I would just go with learning tmux. @AlexanderMills

– Gordster
yesterday





Yeah, I would just go with learning tmux. @AlexanderMills

– Gordster
yesterday


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • 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%2funix.stackexchange.com%2fquestions%2f536340%2fproper-way-to-start-a-background-process%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

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...