0

I have a systemd defined service, that cannot be restarted using systemctl unless I first do a stop. Systemctl claims that the unit does not exists. This happens everytime I reboot until I execute systemctl stop. How can I ensure that the service can be correctly restarted without first having to call systemctl stop?

Example:

# systemctl restart merlind.service
Failed to restart merlind.service: Unit not found.
# systemctl stop merlind.service
# systemctl restart merlind.service

Systemd service definition:

[Unit]
Description=Merlin
After=network.target

[Service]
ExecStart=/usr/bin/merlind --config /path/to/conf --debug
ExecStop=/usr/bin/merlind --config /path/to/conf --kill
Restart=always

[Install]
WantedBy=multi-user.target

The .service file is located at /usr/lib/systemd/system/ and symlinked at: /etc/systemd/system/multi-user.target.wants/

CentOS Linux release 7.5.1804 (Core)

Systemd version: 219

5
  • How did the unit file get into a .wants directory? That's not how systemd unit files are supposed to work. It should be in /etc/systemd/system and symlinked into the .wants directory. And better yet would be to use the tools such as systemctl enable. Commented May 21, 2018 at 12:33
  • 1
    @Patrick sorry! Actually the .service file is at /usr/lib/systemd/system/merlind.service and symlinked at: /etc/systemd/system/multi-user.target.wants. Updated the question. Commented May 21, 2018 at 12:47
  • Just guessing, what happens if you use restart merlind instead of restart merlind.service Commented May 21, 2018 at 17:37
  • @MarkStosberg same behavior if calling with merlind instead of merlind.service unfortunately. Commented May 22, 2018 at 6:47
  • journalctl say anything about it? Commented Jul 9, 2019 at 17:53

1 Answer 1

0

In this case, I had a another service, lets call it ServiceA, which required Merlin described here, as well as some other services. However, one of the services which ServiceA required was missing from the system. Fixing this dependency, also fixed the problem with the Merlin service, which could then be restarted immediately at reboot, without first doing a stop.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.