3

I normally use this command to restart my daemons(e.g. vsftpd):

$sudo /etc/init.d/vsftpd restart

Early today I noticed it said that I can try restart(8) utility. I did:

$sudo restart vsftpd

It worked. But when I tried to restart my apache2:

$sudo restart apache2
> restart: Unknown job: apache2

Why are they different? Of course I can restart apache2 by /etc/init.d/apache2

2 Answers 2

8

The commands start, stop, restart, etc., are links for initctl, and only work for upstart jobs.

Calling directly the script in /etc/init.d/ will give a warning for upstart jobs, for which the use of the script is allowed for convenience, through a wrapper symlinked common script.

Calling the service command always works, both for upstart jobs and for traditional sysv init scripts, so it is the preferred way.

1
  • 1
    And apache2 happens to be a script that is not converted (yet?) to an Upstart job. sudo start x tries to load /etc/init/x.conf.
    – Lekensteyn
    Jul 25, 2011 at 17:53
2

You should be able to use service:

sudo service apache2 restart
2
  • 1
    @Lekensteyn: It is not the same (at least on 10.10), as restart will only refer to initctl, but service is more general and can be used both for upstart and System V init.
    – arrange
    Jul 25, 2011 at 18:00
  • @arrange: confirmed in the source; it first checks for an upstart script in /etc/init/apache2.conf and if that cannot be executed, /etc/init.d/apache2 is tried. The manual page does not include that though.
    – Lekensteyn
    Jul 25, 2011 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .