1.创建一个脚本
#!/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
2.在exit 0之前写好shell脚本
3.给脚本增加执行权限
sudo chmod +x test.sh
4.在启动目录下创建软链接
sudo ln -s test.sh /etc/init.d/
5.添加自启动
cd /etc/init.d/
sudo update-rc.d test.sh defaults 90
说明90为优先级,数字越大,启动越晚。
6.放弃开机启动
sudo update-rc.d -f test.sh remove