First, write a script file that is to be executed when the computer boots. For my case, it was vmscript.sh file that reads
vboxmanage startvm CentOS --type headless
Make sure that this script is runnable.
$ chmod u+x vmscript.sh
Next, run the script yourself to test it works
$ ./vmscript.sh
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/vmscript.sh
That's it! The script shall be executed on each system boot!
No comments:
Post a Comment