方法一, 编辑rc.local脚本
ubuntu开机之后会执行/etc/rc.local文件中的脚本。所以可以直接在/etc/rc.local中添加启动脚本。脚本要添加到 exit 0 之前。
以下是rc.local 初始状态,在exit 0之前添加需要执行的操作即可。
#!/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.
exi