Adding symlink to scripts into rc<number>.d folders to start process during system startup [closed]

江枫思渺然 提交于 2019-12-10 16:15:36

问题


I am using fedora 15.

I am trying to add MYSql daemon to start during system strtup.

I have understood that I will have to add it to rc5.d as it is the default target & is graphical.target.

from inittab:

systemd uses 'targets' instead of runlevels. By default, there are two main targets:

multi-user.target: analogous to runlevel 3
graphical.target: analogous to runlevel 5

From An introduction to services, runlevels, and rc.d scripts :

When the system is shut down, there is another symlink in the /etc/rc0.d and /etc/rc6.d directories (halt and reboot, respectively) that starts with a K instead of an S, which tells init to shut down the process.

I notice that symlink to httpd are present in all the rc<number>.d folders as symlink: K15httpd -> ../init.d/httpd. No symlink is present that starts with S. Makes sense as I have to start it manually.

  • Why is the symlink K15httpd -> ../init.d/httpd present in all the rc<number>.d folders?

  • What should I name the symlink if I want to start httpd during system startup?

  • What is the number that is present in the symlink? i.e. K15httpd -> ../init.d/httpd what is 15 here?

  • I read (here) that the symlink to MYSql should be S98mysql is it right and what should the name to symlink that starts with K should be?

回答1:


The naming convention for the RC scripts is as follows for any in /etc/init.d

  • Start scripts S##<base script name>
  • Kill scripts K##<base script name>

The ## represent the order in which the script will be executed during the run of runlevel control script. The order in which the scripts are executed is:

  • Kill scripts
  • Start Scripts

The order in which it will be execute is the same as the order of files in the output of:

`ls /etc/rc#.d/K*`
`ls /etc/rc#.d/S*`

So by this token the existence of K15httpd script implies that at this runlevel in your case 5 the apache(or another web service) should be stopped.

By same token the kill script for MySQL in lower levels then the one you start it in would be K02MySQL.

You can look at this link to read about the writing the System V init scripts.



来源:https://stackoverflow.com/questions/8837680/adding-symlink-to-scripts-into-rcnumber-d-folders-to-start-process-during-syst

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