ann
          冰是沒有未來的,因為它的永恒
          posts - 107,comments - 34,trackbacks - 0
          Manipulating the start and stop order of Linux servicesThis document (7002295) is provided subject to the disclaimer at the end of this document.

          Environment
          Novell SUSE Linux
          Novell SUSE Linux Enterprise Server 9
          Novell SUSE Linux Enterprise Server 10
          Novell SUSE Linux Enterprise Desktop 10

          Situation
          In some circumstances, the start and stop order of a service needs to be manipulated. 
          How to add start and stop orders to a custom service

          Resolution
          Under the LSB (Linux Standards Base), the start and stop order of services is controlled using the "insserv" package. Unlike Netware, DOS and other operating systems, SUSE calculates the start and stop orders based on dependencies. This idiosyncrasy of Linux has the distinct advantage of providing a faster boot time, but does make things a little more complex.  

          The start and stop scripts are found in /etc/init.d. In the header for the script, you should see something similar:

          ### BEGIN INIT INFO# Provides:        myService# Required-Start: $network# Should-Start: # Required-Stop:# Should-Stop:# Default-Start:  2 3 5# Default-Stop:# Description:    Example Service### END INIT INFO
          If the script lacks the information above (such as a custom script) then you can add it. All LSB-compliant scripts should have a similar header. The only files that should not have this header are any of the .depend.* and boot.local, and after.local.

          The comments above are used by the insserv package to define what the service needs. The "Provides:" line is a pseudo name that can be referenced in other scripts in the "Required-Start," "Should-Start," "Required-Stop," and "Should-Stop" fields. 

          There are ways to manipulate certain services. 

          "$" before a service name refers to a group of services that comprise the pseudo name. These are defined in /etc/insserv.conf. 

          "$ALL" is a reserved name that will make a service run last
          "+" means that the service is optional or that failure of the service will not prevent the referencing service from starting or stopping
          warning

          Do NOT modify the .depend.* files in /etc/init.d directly. Doing so can render a system unbootable. 

          In /etc/init.d/rc?.d directories have the order of the start and stop. The first letter and subsequent two numbers in the name of the file will define the start and stop order. For example, S05myService and S05myService2 would be started at the same time; S05myService and S06myService2 would mean that myService would start before myService2. There is a tendency to manipulate the number of these files directly. This IS NOT advised. Anytime you run "chkconfig" or "insserv" these files will be renamed. It is much better use the LSB method. 

          examples

          Here are few examples of how to manipulate the header of a service defined in /etc/init.d. 

          The following example will start Service "myService" after the network has loaded and will automatically start the service "myOtherService"

          ### BEGIN INIT INFO# Provides:        myService# Required-Start: $network# Should-Start:   myOtherService# Required-Stop:# Should-Stop:# Default-Start:  2 3 5# Default-Stop:# Description:    Example Service### END INIT INFO

          The following example will start the service "myService" last

          ### BEGIN INIT INFO# Provides:        myService# Required-Start: $ALL# Should-Start: # Required-Stop:# Should-Stop:# Default-Start:  2 3 5# Default-Stop:# Description:    Example Service### END INIT INFO
          The following example will start the service "myService" after the network and the optional component "myOtherService"

          ### BEGIN INIT INFO# Provides:        myService# Required-Start: $network +myOtherService# Should-Start: # Required-Stop:# Should-Stop:# Default-Start:  2 3 5# Default-Stop:# Description:    Example Service### END INIT INFO
          defining pseudo services

          In /etc/insserv.conf, pseudo service that are referenced with the "$" in the service scripts are defined. In the event that you need to add a collection of service scripts and reference them only once, they can be added to the insserv.conf file. This is useful for customization to certain environments. 

          For example, if you want to run your firewall rule script every time the network is started, you can modify /etc/insserv.conf to make $network reference "network" and "myFirewall." Assuming that there is a valid script in /etc/init.d with the permissions of 0755, you would change it from:

          $network   network

          to 

          $network   network   myFirewall


          There is one special keyword in the file -- 
          <interactive>. Any service name with <interactive> will require user intervention. 

          making the services run sequentially

          In order to speed the boot process, services are started and stopped in parallel. Under the vast majority, there is no reason to change this behavior. However, if there are problems with this you can change /etc/sysconfig/boot -- simply find the parameter RUN_PARALLEL="YES" to "NO"

          making the changes effective

          After changing the script, you need to run two commands. Replace "myService" with the name of the file you modified. 

          insserv myService
          chkconfig myService on 

          changing novell and third-party provided services

          When changing any provided script from either Novell or a third-party, the changes may and most likely will be over written during a service pack upgrade or a new version of the service. Generally Novell does not release a new version of the /etc/init.d scripts, but it may happen from time to time. 

          adding a custom script

          When a custom script, the permissions of the file need to be 0755 (-rwxr-xr-x).







          Document
          Document ID: 7002295 
          Creation Date: 01-06-2009 
          Modified Date: 01-06-2009 
          Novell Product: SUSE Linux Enterprise Desktop 
          Novell Product: SUSE Linux Enterprise Real Time 
          Novell Product: SUSE Linux Enterprise Server 

          Disclaimer
          The Origin of this information may be internal or external to Novell. Novell makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Novell makes no explicit or implied claims to the validity of this information. 
          Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark information.

          posted on 2009-06-30 17:05 冰是沒有未來的,因為它的永恒 閱讀(415) 評論(0)  編輯  收藏 所屬分類: linux

          當下,把心放下 放下如果是可能的,那一定是在當下,
          不在過去,也不在未來。
          當下放下。唯有活在當下,你的問題才能放下。

          主站蜘蛛池模板: 太原市| 达州市| 沙雅县| 中牟县| 澎湖县| 牡丹江市| 五指山市| 久治县| 宣化县| 昭苏县| 柳州市| 磐安县| 镇赉县| 宜良县| 华安县| 卢龙县| 黔西县| 即墨市| 乌苏市| 溧阳市| 闽侯县| 宜君县| 蒙城县| 宜春市| 乌恰县| 长治县| 穆棱市| 乡城县| 东乌珠穆沁旗| 容城县| 扎赉特旗| 汕尾市| 新泰市| 鄄城县| 莱州市| 兴城市| 肇源县| 湘西| 龙山县| 常山县| 武川县|