# SSH question

## timbradley

OK - a very brief question, and I probably know the answer...

If a command is run over an ssh connection and the terminal window is closed, does the command continue to run on the remote machine??  And if not, is there any way to force it to?

I'd like to run an emerge while at work, but don't want to keep the connection open the whole time...

thanks in advance!!

----------

## merrak

I know there's a way and I think you do it by appending an "&" at the end to "run in the background". You'll have to try it, or maybe someone can confirm / correct me on this one.

----------

## mark_alec

Use screen.

http://gentoo-wiki.com/TIP_Using_screen

----------

## Bones McCracker

You might alternatively try using the job control facilities that are built into BASH to start it as a job and then 'disown' it.

http://www.linuxselfhelp.com/gnu/bash/html_chapter/bashref_6.html

[Edit]: I just tried this, and it didn't work for me.

connected via ssh

sudo emerge -uaD world

(enter password)

^z                            <---- which suspends the process group and assigns it job number 1

1 &                           <---- which resumes the job in the background

Now what I expected to happen was to be presented with my normal prompt and to be able to see the job listed when I type the command 'job'.  Shutting down the terminal would SIGHUP the job, but if I disown it first, I should be able to safely do so.

Instead, I am still receiving all the output from the emerge process on this terminal.

So, while job control might be the answer, I don't know how.

----------

## JeliJami

i vote for screen

but you can do it without:

```
$ nohup your-command &

$ exit
```

your-command will keep running (nohup: no hangup) after you exit, and you can find the output of the command in the file 'nohup.out'

----------

## Bones McCracker

Thanks.

----------

