数字在/etc/rcX.d中是什么意思? [英] what does the numbers mean in /etc/rcX.d?

查看:193
本文介绍了数字在/etc/rcX.d中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在Linux系统启动时自动运行程序,我必须修改/etc/rcX.d,在/etc/init.d中添加一些指向脚本的链接,我有2个问题:

In order to run a program automatically on the boot of the Linux system, I have to modify the /etc/rcX.d, to add some link to the script in /etc/init.d, and I have 2 questions:

  1. 目录名称"/etc/rcNum.d"中的数字是什么意思? 当我将链接文件添加到rcX.d时,应将它们添加到哪个目录?
  2. 在rcX.d目录下的链接文件中,它们的名称中也有一些数字,例如K90xxx或S90xxx,那么数字90是什么意思?是优先事项吗?那么如果将其更改为更大的数字,则意味着该程序将比原先启动?
  1. what does the number in the directory's name "/etc/rcNum.d" means? when i add the link file into the rcX.d which directory should add them to?
  2. the link file under the directory rcX.d, in their names, there are also some numbers, just like, K90xxx or S90xxx,so what's the number 90 means? is it a priority? then when change it to a larger number means the program will be started later than it was?

提前谢谢!

推荐答案

在使用运行级别时,应使用chkconfigservice命令.不要直接修改rcX.d文件夹中的文件.根据LSB,应使用chkconfig启用/禁用脚本. /etc/init.d目录中通常有一个skeleton服务文件,可用于创建自己的服务脚本.如果您的发行版中没有该文件,则可以复制另一个服务脚本并对其进行修改以制作您自己的文件.有了自定义服务脚本后,可以使用以下命令将其激活(假设您的服务称为foo):

You should use the chkconfig and service commands when working with the runlevels. Don't modify the files in the rcX.d folders directly. In accordance with the LSB, you should use chkconfig to enable/disable your scripts. There is usually a skeleton service file in your /etc/init.d directory that you can use to create your own service script. If you don't have that file in your distribution, you can copy another service script and modify it to make yours. Once you have your custom service script, you can activate it with the following command (assuming your service is called foo):

chkconfig --add foo

您可以在服务脚本顶部的注释区域中指定所需的运行级别,也可以通过chkconfig命令的命令行来执行.

You can specify which runlevels you want in the comment area within the top of the service script or you can do it via the command line of the chkconfig command.

要检查服务是否已激活或确保您的服务已正确注册,可以执行以下操作:

To check if a service is activated or to ensure your service was registered correctly, you can do the following:

chkconfig --list foo

要手动启动和停止服务,请使用service命令:

To start and stop your service manually, use the service command:

service foo start
service foo stop

如果使用此方法处理运行级别初始化脚本,则系统将自动在rcX.d文件夹中为每个运行级别创建正确的符号链接.请确保在服务脚本中正确设置依赖项,以便系统可以正确设置要执行的订单号.

If you use this method to work with your runlevel init scripts, the system will automatically create the correct symlinks in your rcX.d folders for each runlevel. Be sure to set the dependencies correctly in your service script so that the system can correctly set the order numbers for execution.

以下一些链接可为您提供更多帮助:

Here's some links to help you more:

  • LSB Runlevels
  • LSB Init Script Comments
  • LSB Init Script Installation

这篇关于数字在/etc/rcX.d中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆