Boot Up Command need to autorun virtualbox at boot

Asked by Vaughan

To Whom It May Concern,

I am currently running Ubuntu Version 10.04 Server 64 bit, I can't upgrade to 12.04 yet as one of our applications is not yet supported by the provider on 12.04.

I have an application which I would like to start automatically everytime the machines boots up, so that in the event that no one is around and the server boots up without anyone around, the application will automatcally be launched.

The command which I would like to run is "sudo VBoxManage startvm 'VirtualMachineName'", which simply starts up a VirtualBox virtual machine by the name of 'VirtualMachineName'. I have tested it manually at the command line and it does work correctly.

I have tried placing the above command in the etc\rc.local file, but does nothing when I test it by rebooting the server. I have also tried using the command 'sudo sleep 10' before the above command in the above file as I have also heard the the rc.local file sometimes runs too quickly.

How would one go about running such a command at the system startup as root?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu virtualbox Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

run:

sudo nano /usr/bin/mystartvbox; sudo chmod +x /usr/bin/mystartvbox

add the below 3 lines:

#!/bin/bash
sleep 30
VBoxManage startvm 'VirtualMachineName

Press CTRL+X, Press Y, Press ENTER

Then run:

sudo nano /etc/rc.local

add the below line above the 'exit 0' line:

mystartvbox &

Press CTRL+X, Press Y, Press ENTER

(including the ampersand), reboot to test and the command will run as root (hence no 'sudo') each and every boot. Sleep doesn't need root access, so why did you prefix it with sudo?

Revision history for this message
Vaughan (vaughan-beckwith) said :
#2

Thank you for your reply, I'll only be able to test it later today. I'll let you know if it worked. Did not know that the sleep command does not require sudo.

Revision history for this message
Best actionparsnip (andrew-woodhead666) said :
#3

Well, think about what sudo does.....

Revision history for this message
Vaughan (vaughan-beckwith) said :
#4

Thanks actionparsnip, that solved my question.