what does the numbers mean in /etc/rcX.d?

强颜欢笑 提交于 2019-12-25 01:52:50

问题


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. 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?

thanks in advance!


回答1:


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

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

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

service foo start
service foo stop

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



回答2:


The number(X) in rcX.d is 'run level'. run levels are related to number of users should log in to system. suppose, runlevel 1 means single user. 3 means multi user and it is default.



来源:https://stackoverflow.com/questions/15310350/what-does-the-numbers-mean-in-etc-rcx-d

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!