13

I just installed Ubuntu 16.04 LTS and found that when I run

usr@server:~$ sudo service <servicename> restart
usr@server:~$

The service is restarted (I can see the status with service <servicename> status), but the shell goes directly back to the command line without the expected:

* Stopping <servicename>     [ OK ]
* Starting <servicename>     [ OK ]
  • Did you take a look at the logs to see if there are any information that could help diagnose the problem? It should be in /var/log/ – Diego Jun 30 '16 at 00:05
  • 2
    There is no problem with the service itself. It's the command prompt returning without output that baffles me. It happens with every service. The command does what is expected (start/stop/restart the service), but there is no output – Eduardo Coria Jun 30 '16 at 00:12

2 Answers2

9

You should not be expecting such output.

For starters, Ubuntu didn't behave this way in earlier versions. Ubuntu was an upstart system for just under a decade, and the behaviour of the service command on Ubuntu has for all those years not resembled what you are expecting. One can see the upstart behaviour of the service command in the image in How do I get service command to print output in 15.10? .

The answer is pretty much the same for you as for the people with Ubuntu version 15.10 last year:

You are using Ubuntu version 16.10, a systemd operating system. Your system service management is no longer performed by upstart (or whatever utility did it on whatever non-Ubuntu operating system you had before). It is performed by systemd.

The service command may be the same … but the Debian/Ubuntu service command is a shell script that tries to auto-detect whether upstart or systemd is the running system service manager, and run the actual native service management commands for upstart and systemd. It executes two pretty much entirely different code paths for upstart and for systemd.

upstart's native service management commands are initctl start, initctl stop, initctl status and so forth. Those print messages as they go.

systemd's native service management commands are systemctl start, systemctl stop, systemctl status and so forth. Those print no output as they operate.

Further reading

JdeBP
  • 3,959
  • 5
    "You should not be expecting such output." is not a great place to start an answer. You're basically saying, "Your opinion is wrong". What you meant to say, I think, is "this is not possible with systemd".

    During the upstart days, Ubuntu DID output... it's in the question for "How do I get service command to print output in 15.10". Prior to 15.10, Ubuntu used upstart and upstart (like sysvinit) was verbose. So please don't say, "It's been like this for a decade". It hasn't. It changed in 15.10. Systemd is not verbose and that's been super irritating ever since distros started deploying it.

    – bobpaul Dec 17 '18 at 18:02
  • The questioner quite clearly told you what xe was expecting, and the upstart output does not resemble that. You are confused, or did not read the question. – JdeBP Feb 27 '19 at 15:40
0

Actually you don't need an OK output. No output means OK. When a service doesn't start properly Ubuntu show you something like this:

Job for php5.6-fpm.service failed because the control process exited with error code. See "systemctl status php5.6-fpm.service" and "journalctl -xe" for details.

In my case this example was a misconfiguration on my php-fpm.conf that unabling the service to start. After follow the instructions I sorted what was causing the error.