Saturday, September 2, 2017

Execute User Scripts on Boot

I wanted to have my VirtualBox guest system start automatically when I turn on the host computer. After some research, here is what I have found out:

First, write a script file that is to be executed when the computer boots. For my case, it was file that reads
vboxmanage startvm CentOS --type headless

Make sure that this script is runnable.
$ chmod u+x

Next, run the script yourself to test it works
$ ./

When everything works fine, edit crontab to run the script on boot. Make sure to run the command below as the user who shall execute the script on boot. That is, don't run it as root unless you want the script to be executed as root.
$ crontab -e

Add the following line when in the crontab
@reboot /path/to/

That's it! The script shall be executed on each system boot!

No comments:

Post a Comment