DEV Community

loading...

Discussion on: How to keep a process running even after closing SSH connection?

Collapse
radulle profile image
Nikola Radulaški

Why not just: CTRL+Z -> bg -> disown? Sure, it suspends your job for a moment but in most cases that is not a problem.

Collapse
bobbyiliev profile image
Bobby Iliev Author

This is a valid point, but I'm afraid that if you do that the jobs that you have in your background would be stopped once you close your SSH session.

Also you would not want to interrupt a critical database import by suspending the job.

Collapse
radulle profile image
Nikola Radulaški

From my experience it doesn't get stopped. One more downside is that you can not own it again. It's like fire and forget kind of solution. Upside is that you do not have to have any preparation for it like in other cases, you run commands as usual.

Thread Thread
bobbyiliev profile image
Bobby Iliev Author

Ah yes, I've just tested that and indeed you are right!

Collapse
asharlohmar profile image
Lohmar ASHAR

I also use this a lot for jobs that are already started and don't want to lose because of some disconnection.
On a day-to-day basis it's a fair fight between screen, mostly for when I didn't had time to take too much care of the logging, and nohup + disown otherwise, because I like to avoid the hassle of cleaning old screen sessions.

Collapse
bayindirh profile image
Hakan Bayındır

Why not add & to the command to start detached, get the pid and disown in a single command. Your job doesn't get stopped, you don't lose anything (if you're capturing packets or doing something timing-critical).