systemd apparently not finding .service file

user3255510 picture user3255510 · Dec 28, 2015 · Viewed 49k times · Source

I've put together a foo.service file for our foo service that runs as a daemon. The service runs fine when I run systemctl start foo (and stop) but systemtcl enable foo results in Failed to issue method call: Invalid argument. The unit file is placed in /etc/systemd/system/foo.service, and has permissions 0755. Setting systemd to debug and running enable gives

Looking for unit files in (highest priority first):`
    /etc/systemd/system
    /run/systemd/system
    /usr/local/lib/systemd/system
    /usr/lib/systemd/system
Looking for SysV init scripts in:
    /etc/rc.d/init.d
Looking for SysV rcN.d links in:
    /etc/rd.c
Failed to issue method call: Invalid argument

Googling around, it seems like systemctl isn't finding the .service file. Is there any way to verify that? If so, how can I fix that? Any other ideas about what might be wrong? Is there more debugging I can enable? The debug info given doesn't really help me narrow down the problem.

foo.service looks like:

[Unit]
Description=Blah Blah Blah

[Service]
ExecStart=/usr/bar/doof/foo
Type=simple
PIDFile=/var/run/foo.pid

[Install]
WantedBy=multi-user.target,graphical.target

EDIT: Yes, I did run systemctl daemon-reload.

Answer

Mark picture Mark · Dec 24, 2016

For people from Google:

  • Validate with sudo systemd-analyze verify NAME.service
  • When using a symlink, make sure it uses absolute path
  • Make sure the name is like /etc/systemd/system/*.service
  • Do sudo systemctl daemon-reload after changes