Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've been managing server installations both on and off Ubuntu flavor for some time - I've become quite adjusted to /etc/init.d/ for restarting servcies. Now I get this message:

root@tatooine:~# /etc/init.d/mysql status
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql status

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the status(8) utility, e.g. status mysql
mysql start/running, process 14048

This seems to have been brought about in the latest LTS of Ubuntu - why? What's so bad about /etc/init.d/ and what/is there a difference between service and /etc/init.d/?

share|improve this question
1  
The Upstart Cookbook contains a good explanation of the rational for switching. –  ændrük Jun 8 '11 at 15:55
add comment

2 Answers 2

up vote 49 down vote accepted

/etc/init.d scripts are the old way of doing things. They come from the System V standard. However, those scripts are fired only in a particular sequence, no real dependencies can be established.

Therefore, upstart has been developed with the intent to substitute all the /etc/init.d scripts with upstart scripts (in /etc/init).

service allows the smooth transition from /etc/init.d scripts to upstart scripts. When in the future more on more scripts are transferred to upstart, service will still work, because it finds both possibilties.

share|improve this answer
2  
Upstart is going to be phased out now, right? –  wrongusername Mar 2 at 15:11
1  
systemd will replace upstart once plans are in place - 14.04 LTS will use upstart. This was announced by Mark Shuttleworth, in a post titled Losing graciously –  RichardWigley Apr 6 at 14:05
add comment

Also check the man page for the service command: man service

service runs a script in a predictable environment (working directory is / and only 2 environment variables are set: LANG and TERM). It also adds the ability to do --full-restart. So to sum up:

  1. service may run scripts from either /etc/init or /etc/init.d (upstart or System V)
  2. service runs scripts in a predictable environment.

The "predictable environment" aspect can cause you problems if your script depends on an environment variable for some reason. There is probably a way to get around that, but I don't know what it is, and that's beyond the scope of this question :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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