Wednesday, November 14, 2007

Service and /etc/init.d

Christer Edwards asked in his blog today about the difference between starting a init-script through /etc/init.d and the command service that exist on at least Red Hat boxes. I left a comment on his blog, but thought it would be nice to write some more about it here. It is not the first time I got the question.

What Christers blog was about was that you can get the service command on Ubuntu too:
sudo aptitude install sysvconfig

At boot of your Linux machine the scripts in the /etc/rcX.d are started. X corresponds to your run level. On clients is it normally 5 and servers 3, but all Debian and Ubuntu-boxes uses 2. Anyway, those scripts are actually links to /etc/init.d/. The software that has called these scripts has traditionally been init, now days it is upstart on Ubuntu. Init does not necessary have the same environment variables set as you will have when you log in as root. Therefore is the service command fix so that the environment variables are the same as when starting the services on boot. Starting a service throug /etc/init.d does not guarantee that, i.e. a service starting when you loged in as root may not start at boot since some variables are missing.

No comments: