Linux设置开机自启动

来源:互联网 发布:mysql pdf 微盘 编辑:程序博客网 时间:2024/05/16 09:27

1、进入/etc/init.d文件夹,编辑一个自定义的开机自启动脚本例如auto_start

#!/bin/bashtouch /auto_start.txtls /dev > /auto_start.txt

2、设置脚本文件auto_start的权限为可执行:

chmod 777 auto_start

3、执行chkconfig命令,chkconfig的man手册解释是:enable or disable system services,chkconfig  is used to manipulate the runlevel links at boot time,就是在系统启动阶段开启或者关闭一个系统服务,用来检查,设置系统的各种服务。执行命令:

chkconfig auto_start on
运行后出现错误提示:

/sbin/insserv:No such file or directory
一般这个文件会在/usr/lib/insserv/insserv中,所以解决办法是:

ln -s /usr/lib/insserv/insserv /sbin/insserv
然后继续执行chkconfig命令即可打开auto_start服务,然后重启系统发现根文件目录下有了auto_start.txt文件了,代表自启动程序运行了。