CentOS 增加自启脚本

CentOS 增加自启脚本
双木老林方式一
直接修改 /etc/rc.local ,将任务加上即可。
但是不推荐这种方式 = =
方式二
通过增加一个 autostart.sh 的脚本
新增脚本
1 | vim /etc/init.d/autostart.sh |
1 |
|
#!/bin/sh ==> 告诉系统使用的 shell
#chkconfig: 2345 80 90 ==> 表示在2/3/4/5运行级别启动,启动序号(S80),关闭序号(K90)
#description: xxx ==> 表示的是服务的描述信息
注意: 第二行( chkconfig )和第三行( description )必写,负责会出现如“服务 autostart.sh 不支持 chkconfig”这样的错误。
设置权限
1 | chmod +x /etc/init.d/autostart.sh |
设置开机启动
1 | chkconfig --add autostart.sh |
评论
匿名评论隐私政策








