101

I'm working with a custom service which essentially runs a web server, called thisismywebserver. Currently it's not working (ie I get an "Unable to Connect" error trying to access a page).

When I run this command service thisismywebserver status to see the status of the service I see that the status is "active (exited)". Does this mean the service has stopped working? If not, then what does this mean?

root@thisismywebserver-testing:~# service thisismywebserver status
● thisismywebserver.service - LSB: ThisIsMyWebServer server
   Loaded: loaded (/etc/init.d/thisismywebserver)
   Active: active (exited) since Sun 2015-11-08 23:01:33 EST; 18h ago

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

2 Answers 2

40

It seems you are running a system with systemd yet you are using sysV commands. Did you create a sysV init script or a systemd unit file?

State active (exited) means that systemd has successfully run the commands but that it does not know there is a daemon to monitor.

If there is you must define it in the unit file by configuring the Type and ExecStart options appropriately according to whether the process you start is the main proces, forks child processes and exits etc.

Check the different systemd man pages or update your question and post the unit file or init script.

5
  • Thanks for your answer! I have just started work on this system since the previous developer became unavailable, so I don't know which of those alternatives applies. I'll have a read of the man pages you mention, and see if I can figure it out. Nov 10, 2015 at 1:23
  • 1
    @Bram Can you let us know how to specify that? Is it via the ExecStart and ExecStop ? I am facing same issue
    – RajSanpui
    Jan 14, 2016 at 13:30
  • 2
    @ whoever downvoted my answer: please comment and explain why you feel this answer is not correct or not complete.
    – Bram
    May 5, 2017 at 11:11
  • The LSB: in the supplied description tells you that the questioner did not create a service unit, Bram. See unix.stackexchange.com/a/386876/5132 and unix.stackexchange.com/a/387314/5132 .
    – JdeBP
    Sep 26, 2017 at 4:06
  • 4
    This state can also mean that the service has been started but its process immediately exited, most likely due to a fatal error. This happened to me with a misconfigured openvpn service.
    – jlh
    May 23, 2018 at 16:07
10

I met the same issue showing active (exited). The root cause is my shell process just quits after it starts some service daemon via start-stop-daemon command.

And the solution is changing my shell process into an infinite loop instead of quitting directly. With this way, it shows active (running) after executing systemctl start my-service-name.service.

Additionally, in this loop the shell process monitors the state of the service daemon. Once the shell process detects the service daemon goes into some error state, it just breaks from the infinite loop and exits.

4
  • 2
    active (exited) is not a problem in itself. For example, if the unit file sets RemainAfterExit=true, a service that exits is reported as active. Example: On my Ubuntu server, the ufw service initializes the firewall at system startup. It's a oneshot service, which performs one task then exits. However, it's still considered active, perhaps because inactive would confuse users. After all, the firewall is in place. Feb 1, 2021 at 2:52
  • I said "perhaps because inactive would confuse users". This might be true, but the real reason is to prevent systemctl start ufw to initialize the firewall a second time. Since the service is active, starting it has no effect. Feb 1, 2021 at 2:59
  • @berndbausch It's not a problem and the daemon is working fine though it shows "active(exited)" that is a little confusing in the first sight.
    – azhuang
    Feb 2, 2021 at 6:32
  • 1
    See example 4 on the systemd.service manual page: freedesktop.org/software/systemd/man/systemd.service.html. Feb 2, 2021 at 7:23

You must log in to answer this question.

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