|
From: Sabine Elsner on 6 May 2008 17:20 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: Robert Heller on 6 May 2008 17:49 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
|
Pages: 1 Prev: Why can't I use `date` to set the date ? Next: Cygwin script issue |