23

From what I understood, the /etc/init.d directory contains the scripts executed by init at boot time. Is that only for Debian or for Ubuntu 14.04 as well?

I am wondering because I have several scripts in the init.d directory but they do not seem to be run when the server starts. Is there a log to check?

For example, when I installed supervisor (apt-get install supervisor), it created an init script in /etc/init.d/supervisor which is supposed to start it but when I start my server, supervisor does not run. I have some other examples so it does not seem to be related to the supervisor script only.

Also, what is the difference between /etc/init.d and etc/init ? I am confused.

Thanks

2

1 Answer 1

33

The scripts in /etc/init.d/ are scripts that control services. Controlling means that they take care of starting, stopping and similar actions.

They are not automatically executed at startup. Instead, you must assign scripts to runlevels, which is done with the update-rc.d command on Debian-based systems (which Ubuntu is).

For example, to add your supervisor service to all default runlevels, you would execute

sudo update-rc.d supervisor defaults

Also, you're asking for the difference between /etc/init.d and /etc/init:

  • /etc/init.d contains the service scripts,
  • /etc/init contains configuration for these scripts (descriptions. dependencies, post-/pre-actions). However IIRC, /etc/init is specific to SysV init.
5
  • 2
    oh ok, I misunderstood the purpose of the init scripts then. When I read the supervisor documentation, it sounded like using a init script would make supervisord run automatically on startup: supervisord.org/… I tried the sudo update-rc.d command but I get this message System start/stop links for /etc/init.d/supervisor already exist.. Why doesn't it work?
    – Michael
    Oct 8, 2014 at 22:55
  • Also, I made more research and I found that looking at service --status-all, I can see the services that are started at OS boot (the ones with a "+" sign in front of them) and supervisor is not since it has a "-" sign. :/
    – Michael
    Oct 8, 2014 at 22:55
  • Ok, that's a bit weird. Could you do the following: Create a new post (and maybe better on Unix/Linux SE) describe that phenomenon there. Because it would be easier to discuss this in a new post, and it's likely to attract more readers.
    – lxg
    Oct 9, 2014 at 7:58
  • 7
    This answer seems like misinformation to me. isn't /etc/init part of upstart and /etc/init.d/ the old Sys V Init?
    – erik258
    Jan 9, 2015 at 18:49
  • 1
    It is true that /etc/init was introduced by Upstart, while /etc/init.d goes back to SysV. However, my point was that /etc/init.d contains scripts to be executed, while /etc/init contains configuration. But, upstart is dead anyway, and systemd introduces /etc/systemd. Note that /etc/init as well as /etc/init.d still exist on current Ubuntus (15.04 here), but I guess these are just transitional files installed by packages that support all three init systems.
    – lxg
    Jun 3, 2015 at 5:24

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.