Linux中如何设置服务自启动 FAQ: Ubuntu 12.04 64bit /sbin/insserv: No such file or directory
2013-04-14 23:43
597 查看
转载连接:http://os.51cto.com/art/201301/377515.htm
有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务,主要用三种方式进行这一操作:
注意:
这三种方式主要用于以redhat为基础的发行版
如果还不知道运行级别是什么,那么最好先看看相关资料再实验
第一种方式:ln -s 建立启动软连接
在Linux中有7种运行级别(可在/etc/inittab文件设置),每种运行级别分别对应着/etc/rc.d/rc[0~6].d这7个目录:
Tips:/etc/rc[0~6].d其实是/etc/rc.d/rc[0~6].d的软连接,主要是为了保持和Unix的兼容性才做此策。
这7个目录中,每个目录分别存放着对应运行级别加载时需要关闭或启动的服务,由详细信息可以知道,其实每个脚本文件都对应着/etc/init.d/目录下具体的服务。
K开头的脚本文件代表运行级别加载时需要关闭的,S开头的代表需要执行:
因此,当我们需要开机启动自己的脚本时,只需要将可执行脚本丢在/etc/init.d目录下,然后在/etc/rc.d/rc*.d中建立软链接即可:
此处sshd是具体服务的脚本文件,S100ssh是其软链接,S开头代表加载时自启动。
如果需要在多个运行级别下设置自启动,则需建立多个软链接,这种方式比较繁琐,适用于自定义的服务脚本。
如果系统中已经存在某些服务(比如安装apache时就会有httpd服务项),可以使用下面的两种方式:
第二种方式:chkconfig
如果需要自启动某些服务,只需使用chkconfig 服务名 on即可,若想关闭,将on改为off。
在默认情况下,chkconfig会自启动2345这四个级别,如果想自定义可以加上--level选项:
上面我们先将sshd服务的所有启动级别关闭,然后使用--level选项启动自定义级别;
Tips:--list选项可查看指定服务的启动状态,chkconfig不带任何选项则查看所有服务状态。
FAQ: 原文链接:http://loginroot.com/ubuntu-12-04-64bit-sbininsserv-no-such-file-or-directory/
使用第二种方式设置服务时候会出现错误信息(Ubuntu),/sbin/insserv: No such file or directory
解决方案:ln -s /usr/lib/insserv/insserv /sbin/insserv
使用上面方式解决后,服务能设置成功,但是会报警告信息,可参照原链接的回复
Kamal:
I am getting error/warnings:
chkconfig -s ssh on
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script ‘console-setup’ missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `console-setup’
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `console-setup’
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script ‘screen-cleanup’ missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup’
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `screen-cleanup’
The script you are attempting to invoke has been converted to an Upstart
November 15, 2012, 3:08 pm
Reply
nsc:
Well, those are warnings because of missing LSB tags.
You can ignore messages (chkconfig shows that service is on, doesn’t it?), or add tags by Yourself:
http://wiki.debian.org/LSBInitScripts
Actually, chkconfig is the way RHEL/CentOS family system adds startup scripts.
The right way for Ubuntu is with update-rc.d.
For example:
update-rc.d ssh defaults
第三种方式:ntsysv 伪图形
ntsysv和chkconfig其实是一样的,只不过加上了图形而已;
启动ntsysv有两种方式,一是直接在命令行中输入ntsysv,二是使用setup命令,然后选择系统服务:
默认情况下,当前运行级别为多少,在ntsysv中设置的启动服务的级别便是多少,比如,我当前的运行级别是3,那么我在伪图形界面中选择启动服务后,它的运行级别也会是3。
如果想自定义运行级别可使用ntsysv --level方式:
以上三种操作需要保证服务脚本文件可执行,并且要有root权限,其中,第一种方式多用于自定义脚本,第二、三种多用于系统已存在的服务,比如ftp、samba、ssh、httpd等等,并且,要做相关设置需要弄清楚运行级别的问题。
Tips:如果想手动启动某服务,传统的方式是 /etc/init.d 服务名 start。
实际上还可以这样,service 服务名 start:
有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务,主要用三种方式进行这一操作:
ln -s 在/etc/rc.d/rc*.d目录中建立/etc/init.d/服务的软链接(*代表0~6七个运行级别之一) chkonfig 命令行运行级别设置 ntsysv 伪图形运行级别设置
注意:
这三种方式主要用于以redhat为基础的发行版
如果还不知道运行级别是什么,那么最好先看看相关资料再实验
第一种方式:ln -s 建立启动软连接
在Linux中有7种运行级别(可在/etc/inittab文件设置),每种运行级别分别对应着/etc/rc.d/rc[0~6].d这7个目录:
Tips:/etc/rc[0~6].d其实是/etc/rc.d/rc[0~6].d的软连接,主要是为了保持和Unix的兼容性才做此策。
这7个目录中,每个目录分别存放着对应运行级别加载时需要关闭或启动的服务,由详细信息可以知道,其实每个脚本文件都对应着/etc/init.d/目录下具体的服务。
K开头的脚本文件代表运行级别加载时需要关闭的,S开头的代表需要执行:
因此,当我们需要开机启动自己的脚本时,只需要将可执行脚本丢在/etc/init.d目录下,然后在/etc/rc.d/rc*.d中建立软链接即可:
[root@localhost ~]# ln -s /etc/init.d/sshd /etc/rc.d/rc3.d/S100ssh
此处sshd是具体服务的脚本文件,S100ssh是其软链接,S开头代表加载时自启动。
如果需要在多个运行级别下设置自启动,则需建立多个软链接,这种方式比较繁琐,适用于自定义的服务脚本。
如果系统中已经存在某些服务(比如安装apache时就会有httpd服务项),可以使用下面的两种方式:
第二种方式:chkconfig
如果需要自启动某些服务,只需使用chkconfig 服务名 on即可,若想关闭,将on改为off。
在默认情况下,chkconfig会自启动2345这四个级别,如果想自定义可以加上--level选项:
上面我们先将sshd服务的所有启动级别关闭,然后使用--level选项启动自定义级别;
Tips:--list选项可查看指定服务的启动状态,chkconfig不带任何选项则查看所有服务状态。
FAQ: 原文链接:http://loginroot.com/ubuntu-12-04-64bit-sbininsserv-no-such-file-or-directory/
使用第二种方式设置服务时候会出现错误信息(Ubuntu),/sbin/insserv: No such file or directory
解决方案:ln -s /usr/lib/insserv/insserv /sbin/insserv
使用上面方式解决后,服务能设置成功,但是会报警告信息,可参照原链接的回复
Kamal:
I am getting error/warnings:
chkconfig -s ssh on
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script ‘console-setup’ missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `console-setup’
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `console-setup’
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script ‘screen-cleanup’ missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `screen-cleanup’
insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `screen-cleanup’
The script you are attempting to invoke has been converted to an Upstart
November 15, 2012, 3:08 pm
Reply
nsc:
Well, those are warnings because of missing LSB tags.
You can ignore messages (chkconfig shows that service is on, doesn’t it?), or add tags by Yourself:
http://wiki.debian.org/LSBInitScripts
Actually, chkconfig is the way RHEL/CentOS family system adds startup scripts.
The right way for Ubuntu is with update-rc.d.
For example:
update-rc.d ssh defaults
第三种方式:ntsysv 伪图形
ntsysv和chkconfig其实是一样的,只不过加上了图形而已;
启动ntsysv有两种方式,一是直接在命令行中输入ntsysv,二是使用setup命令,然后选择系统服务:
默认情况下,当前运行级别为多少,在ntsysv中设置的启动服务的级别便是多少,比如,我当前的运行级别是3,那么我在伪图形界面中选择启动服务后,它的运行级别也会是3。
如果想自定义运行级别可使用ntsysv --level方式:
以上三种操作需要保证服务脚本文件可执行,并且要有root权限,其中,第一种方式多用于自定义脚本,第二、三种多用于系统已存在的服务,比如ftp、samba、ssh、httpd等等,并且,要做相关设置需要弄清楚运行级别的问题。
Tips:如果想手动启动某服务,传统的方式是 /etc/init.d 服务名 start。
实际上还可以这样,service 服务名 start:
相关文章推荐
- ubuntu下如何处理出现“ unable to execute ./DrClientLinux: No such file or directory”,“没有那个文件或目录”的问题。
- ubuntu 64bit arm-linux-gcc: No such file or directory 问题
- ubuntu 13.10:bash: ./arm-none-linux-gnueabi-gcc: No such file or directory
- ubuntu 64位 arm-linux-gcc: No such file or directory
- 在ubuntu 64位的机器上执行arm-linux-gcc提示 no such file or directory
- (ubuntu)linux 安装coffeescript后,出现/usr/bin/env: node: No such file or directory
- linux可执行文件执行时提示No such file or directory(docker环境中运行的ubuntu镜像)
- ubuntu添加qmake 出现错误 qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
- Ubuntu 16.04出现:qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
- ubuntu 64bit “arm-linux-gcc: No such file or directory”问题的解决方法
- ubuntu 64bit “arm-linux-gcc: No such file or directory”问题的解决方法
- linux Ubuntu C++:“fatal error: iostream.h: No such file or directory ”
- 32位ubuntu 12.04 下 error: gnu/stubs-32.h: No such file or directory错误解决办法
- (原創) 如何解決Java在Linux上『libXp.so.6: cannot open shared object file: No such file or directory』的錯誤訊息? (OS) (Linux) (CentOS) (Java)
- [Linux][ubuntu][Perl]bad interpreter: No such file or directory
- Ubuntu 12.04 alternate 64位 执行文件,显示:bash: ***: No such file or directory
- Linux 有问必答:如何修复“fatal error: openssl/aes.h: No such file or directory
- 在Ubuntu 64位机器上执行arm-linux-gcc命令提示无法加载库,no such file or directory
- ubuntu 64位的机器上执行arm-linux-gcc提示 no such file or directory
- linux java jdk环境变量设置之后,依旧提示 No such file or directory