ubuntu操作系统创建开机启动脚本

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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容