Linux 的开机流程一般为:Bios > Grub > Kernel > Init > ###
划掉,这是无关紧要的。
Linux的脚本自启方法有很多,我目前只知道三种:
1、init.d 的自启
在/etc/init.d/中创建文件:
cd /etc/init.d
vi start.sh #假如这是你要启动的脚本
![](https://img-blog.csdnimg.cn/20190417144412677.png)
chmod +x start.sh #增加执行权限
然后直接:
sudo update-rc.d start.sh 90
#这个最简单,不过好像只能在Ubuntu下这么做Cent OS 不行
2、rc.local 中添加命令或脚本
cd /etc/ #进入etc
vi rc.local
#还是以 start.sh 为主角,假设它为/root/
/root/start.sh #请在touch 下面加入
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190417145558371.png)
保存退出。
#不过,也有网友说这个自启好像很容易失败,而且测试不方便。
3、注册shell为系统服务(这个我还没有试过)
cd /etc/init.d/
vi start.sh
chmod +x start.sh
chkconfig --addstart.sh #加入系统服务列表
chkconfig start.sh on #设置开关(no/off)
chkconfig --list start.sh #查看服务
这是本菜鸡,看到的一些方法,欢迎大佬,在评论,介绍其它的方法给我。
谢谢!
有些东西是看了这个,才会的,有兴趣请自行观看: https://blog.csdn.net/lylload/article/details/79488968