I ssh into a server than start a job (for instance rsync), then I just want to be able to log out from the server and let the job run its course. But if I just do rsync ... &
I think it's still connected to the tty in some way, and that the job dies when the tty goes away when logging out. Is there any (easy) way to disconnect the process from the tty to be able to log out without the process terminating?
-
Which operating system?– John GardeniersMar 24, 2010 at 12:45
Add a comment
|
5 Answers
you could start it in a screen
-
+1 also to using screen. It's simply to use and once you get used to it, you'll never want to be without it. I would consider it one the most valuable tools I use in the Unix world.– MT.Mar 24, 2010 at 12:52
-
Thanks but n00b as I am I don't know how. Example cmdline might be helpful. May 3, 2010 at 10:10
Use setsid
and redirect handles 1 and 2 to /dev/null
.
e.g.
setsid \
perl -e 'for ( my $i = 0; 1; $i++ ) { $0 = "forever $i"; sleep( 1 ); }' \
1>/dev/null \
2>/dev/null
Without setsid
and a trailing ampersand the command ps ax
shows:
13526 pts/4 S 0:00 forever 11
With setsid
and no trailing ampersand the command ps ax
shows:
13520 ? Ss 0:00 forever 68
...indicating no attached TTY.
In Linux (Ubuntu at least) you can use start-stop-daemon
If all you want is to start a process and leave it running, you can use
at now