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

  • 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. – Patrick May 21 '18 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. – Jacob May 21 '18 at 12:47
  • Just guessing, what happens if you use restart merlind instead of restart merlind.service – Mark Stosberg May 21 '18 at 17:37
  • @MarkStosberg same behavior if calling with merlind instead of merlind.service unfortunately. – Jacob May 22 '18 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.