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

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

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.

link|improve this answer
feedback

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

also check,

shopt -u huponexit

link|improve this answer
That's great - thanks! Perhaps nohup will work, too. – Adam Matan Aug 26 '09 at 9:06
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.