From: Sabine Elsner on
Assume I opened a SSH session to a remote Linux server.

I want to start a long running command on that remote system and put that command in background
so that I can logout (from SSH session) while the command is still running and not aborted.

Normally I would have to put the command in such a case in background by appending a " &" at the end
of the command line. However this does not work if I redirect the output like in:

rsync ...... >>logfile 2>&1 &

I guess I have to mask the appended "&".

How do I do this otherwise?

Sabine
From: Ignoramus2305 on
On 2008-05-06, Sabine Elsner <gizmo_3(a)yahoo.de> wrote:
> Assume I opened a SSH session to a remote Linux server.
>
> I want to start a long running command on that remote system and put that command in background
> so that I can logout (from SSH session) while the command is still running and not aborted.

man nohup

> Normally I would have to put the command in such a case in background by appending a " &" at the end
> of the command line. However this does not work if I redirect the output like in:
>
> rsync ...... >>logfile 2>&1 &
>
> I guess I have to mask the appended "&".
>
> How do I do this otherwise?
>
> Sabine

--
Due to extreme spam originating from Google Groups, and their inattention
to spammers, I and many others block all articles originating
from Google Groups. If you want your postings to be seen by
more readers you will need to find a different means of
posting on Usenet.
http://improve-usenet.org/
From: Robert Heller on
At 06 May 2008 21:20:51 GMT gizmo_3(a)yahoo.de (Sabine Elsner) wrote:

>
> Assume I opened a SSH session to a remote Linux server.
>
> I want to start a long running command on that remote system and put that command in background
> so that I can logout (from SSH session) while the command is still running and not aborted.
>
> Normally I would have to put the command in such a case in background by appending a " &" at the end
> of the command line. However this does not work if I redirect the output like in:
>
> rsync ...... >>logfile 2>&1 &
>
> I guess I have to mask the appended "&".
>
> How do I do this otherwise?

ssh remote.machine.whatever sh -c 'nohup rsync ...... >>logfile 2>&1 &'

Note: 'logfile' lives on the remote machine's file system. You have to
quote the whole command string and pass it to a 'super' shell, one that
will exit once the background job fades into the background. nohup
prevents the forked process from being killed when the parent (super)
shell exits.

>
> Sabine
>

--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk

From: darthludi on
Sabine Elsner wrote:
> Assume I opened a SSH session to a remote Linux server.
>
> I want to start a long running command on that remote system and put that command in background
> so that I can logout (from SSH session) while the command is still running and not aborted.
>
> Normally I would have to put the command in such a case in background by appending a " &" at the end
> of the command line. However this does not work if I redirect the output like in:
>
> rsync ...... >>logfile 2>&1 &
>
> I guess I have to mask the appended "&".
>
> How do I do this otherwise?
>
> Sabine

Take a look at screen