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 login remotely to a machine with Virtualbox installed by launching:

ssh -Y root@virtualbox

After that, I launch a Virtual Machine:

nohup VBoxSDL --startvm vm1

or

nohup VBoxSDL --startvm vm1 &

After that, I don't have the prompt anymore.

Then, if I switch off my local machine, the virtual machine goes down (no matter whether I use & or not).

How can I keep it running after I switch off my local machine?

share|improve this question

3 Answers 3

Try: (nohup VBoxSDL --startvm vm1 &) &

I believe the use of the brackets should result in a new shell being spawned to run the commands within them. This shell is then dis-associated from your own through the use of the &.

As an alternative if you use bash as your shell try running 'disown -h' after the command to start the VM. This is a shell built in function which should also dis-associate the running process from your current shell.

share|improve this answer
    
Alternatively: nohup VBoxSDL --startvm vm1 </dev/null >/dev/null 2>&1 & –  jlliagre Sep 22 '10 at 12:48

On the host of visturalbox

$ nohup VBoxHeadless --startvm centos5.6 &

or

$ nohup VBOxManage startvm centos5.6 --type headless &

Then logout.

Login again and check whether it is still running.

$ VBoxManage list runningvms
"centos5.6" {d46f4510-c95e-4000-b92e-2dc67437174e}

Now it should be running when you are not logged in. Let's say that this virtualbox is named as virtualbox.mydomain.com. Then, from a remote machine

$ ssh yoichi101@virtualbox.mydomain.com
yoichi101@virtualbox.mydomain.com's password: 
Last login: Wed Jun 22 19:57:31 2011
share|improve this answer
    
@Daniele did this work? –  Matt Jun 23 '11 at 3:38
    
Yes, it worked. The manual says that using VBoxHeadless is better for dealing with error messages etc. –  Yoichi Takayama Jun 26 '11 at 5:31
    
Sometimes it seemed to work without the nohup or &. Some commands do this by automatically doing the nohup or &. But it was more consistent with both. After the &, you mention that your prompt disapears. This is normal. Wait till nohup message says that it is appending the output to the nohup. Then, hit Return. This should give you back the prompt ($ or #), then you logout or close down the shell. (But, of course, you don't "power down" the host machine!) –  Yoichi Takayama Jun 26 '11 at 6:39

Perhaps use screen instead.

share|improve this answer

Your Answer

 
discard

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