1

When I run a process on a remote Linux machine, the process stops if the connection is terminated for some cause. This behavior is reasonable, because otherwise irrelevant processes would keep running forever.

However, is there a way to prevent this from happening? Namely, I want to open a remote shell, run a process and direct its output to a log file, and log out - but keep the process running.

Thanks,

Udi

Adam Matan
  • 8,740

2 Answers2

3

You can either use a screen session or push the process to background disconnecting it from the shell.

also check,

shopt -u huponexit

nik
  • 57,042
2

Well first option can be to spawn you program as another process with the & operator like

$ myprogram > file.log &

Or you can have a look at the screen command where you can store and retrieve your terminal sessions.

Daff
  • 685