Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Which operating system? –  John Gardeniers Mar 24 '10 at 12:45

5 Answers 5

you could start it in a screen

share|improve this answer
    
+1 to using screen. –  gravyface Mar 24 '10 at 12:49
    
+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 '10 at 12:52
    
Thanks but n00b as I am I don't know how. Example cmdline might be helpful. –  Jonas Byström May 3 '10 at 10:10
up vote 4 down vote accepted
nohup rsync ... &

Seems to do exactly what I want.

share|improve this answer

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.

share|improve this answer

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
share|improve this answer

Debian and Ubuntu have a package called daemon which seems to be part of the libslack project.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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