yngwiemale 写了:各位高手,本人不会编程,由于喜爱ubuntu系统
已将主要系统替换未ubuntu14.04 虚拟机安装xp使用一些办公软件
目前每次开机时 都需要手动打开终端 在终端中输入optirun virtualbox 通过独立显卡启动vb
最近了解到脚本这个东西 希望能帮忙做一个 开启后20秒自动执行上述流程的脚本
本人并不是伸手党 实在是苦于知识匮乏
希望在未来尝试学习脚本的制作
十分感谢
-----------
easy money.
主要实现原理:
1、/etc/rc.local可以帮你自动启动一些程序。
2、安装virtualbox之后会一并安装vboxmanage
root@userver:~# vboxmanage -h |head
Oracle VM VirtualBox Command Line Management Interface Version 4.3.24
(C) 2005-2015 Oracle Corporation
All rights reserved.
Usage:
VBoxManage [<general option>] <command>
General Options:
.....
具体实现不需要太多的东西,将你的/etc/rc.local替换成如下内容即可。
如果没有修改应该是下面这些内容。
root@userver:~# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
修改之后替换成如下内容:
root@userver:~# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sleep 20
#start virtual box in background
vboxmanage startvm <vmname> &
-----end
或者可以使用at指令也可以完成上面的任务。