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;
}
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
add a comment |
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
1
Neithernohup
nordisown
will do anything related to theTERM
signal, only theHUP
signal (nohup
makes it ignore it anddisown
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 eithertmux
or GNUscreen
?
– 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
add a comment |
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
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
background-process daemon disown
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
Neithernohup
nordisown
will do anything related to theTERM
signal, only theHUP
signal (nohup
makes it ignore it anddisown
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 eithertmux
or GNUscreen
?
– 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
add a comment |
1
Neithernohup
nordisown
will do anything related to theTERM
signal, only theHUP
signal (nohup
makes it ignore it anddisown
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 eithertmux
or GNUscreen
?
– 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
add a comment |
1 Answer
1
active
oldest
votes
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.
yes I heartmux
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
yes I heartmux
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
add a comment |
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.
yes I heartmux
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
add a comment |
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.
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.
edited 2 days ago
answered 2 days ago
GordsterGordster
2061 silver badge6 bronze badges
2061 silver badge6 bronze badges
yes I heartmux
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
add a comment |
yes I heartmux
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
Neither
nohup
nordisown
will do anything related to theTERM
signal, only theHUP
signal (nohup
makes it ignore it anddisown
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 GNUscreen
?– 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