Find the answer to your Linux question:
Page 1 of 5 1 2 3 4 5 LastLast
Results 1 to 10 of 41
As we all know, init is the first process that is started after the kernel is loaded. Since I'm running on level 5 (GUI), when I stop the system, I'm ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319

    Question about init


    As we all know, init is the first process that is started after the kernel is loaded. Since I'm running on level 5 (GUI), when I stop the system, I'm assuming that the level of this gets changed to zero. Since level 5 already contains the correct links to stop services, why is it necessary to switch to level 0 where there are another set of correct links to stop services?
    The best things in life are free.

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    The links that stop services in runlevel 5 are only executed when you _enter_ runlevel 5. Nothing is ever done when you exit a runlevel, only when you enter a runlevel. Therefore the stop scripts are present in runlevel 0. Please note that when you reboot, you enter runlevel 6.

  3. #3
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    OK, I thought that scripts ran differently but I see your point. I have yet another question. Let's say the user is running on level 1, which I've never done, but looking at /etc/rc.d/rc1.d, I see tons of scripts that have a prefix with K (to stop services). Why do we even bother stopping these services when they aren't even running?
    The best things in life are free.

  4. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Since you might enter from a runlevel that do have them running. For example, if you have a server that's running in runlevel 3 normally, and you decide to take it down for maintanence for some time, you then make it enter runlevel 1. That will make the rc scripts terminate all network services that you normally have running in runlevel 3, so that it truly does become a single user system.

  5. #5
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Ah, that clarifies things. How about this scenario: At runlevel 5, there is a script for apache to shut down. This script is also available at level 0. When I shut the system down, why is it then that the machine only tries to shut apache down once? Perhaps I missed the output but I only see the message once.
    The best things in life are free.

  6. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That is since the kill script at runlevel 5 has nothing to do with it. When you are in runlevel 5 and then go to runlevel 0, nothing is ever done with the scripts in runlevel 5. Whenever you switch runlevel, this is precisely what happens, nothing more and nothing less:
    1. The kill scripts in the new runlevel are run.
    2. The start scripts in the the new runlevel are run.
    The old runlevel is simply not relevant in any way.

  7. #7
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Right. I'm sorry about that last post. I don't know what I was thinking.
    Going back to it, it should try to kill the apache service going INTO level 5. Then why is it that I don't see this message at boot?
    The best things in life are free.

  8. #8
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Sorry, I haven't told you about /var/lock/subsys. Each time a service is stopped or started successfully, it updates /var/lock/subsys, so that a file with the name of the service is present there only if the service is running, and the rc scripts only run the kill scripts or start scripts if it is necessary as indicated by the files there. Therefore, since apache isn't started when you start your system, the rc scripts doesn't attempt to kill it.

  9. #9
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Then why is it that level 0 tries to kill it?
    The best things in life are free.

  10. #10
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Because when it was started in runlevel 5, the service script created /var/lock/subsys/httpd. When it sees that when you go to runlevel 0, it takes that as the indication that apache is running, and therefore stops it.

Page 1 of 5 1 2 3 4 5 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •