Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

systemd apparently not finding .service file

Tags:

systemd

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.

like image 343
user3255510 Avatar asked Dec 28 '15 22:12

user3255510


People also ask

What is a .service file?

The database server requires a Services file, which contains information about the known services on your network. The Services file is typically located in %windir%\System32\drivers\etc\services.

Where do I put systemd service files?

d/ " directories for system services can be placed in /usr/lib/systemd/system or /run/systemd/system directories. Drop-in files in /etc/ take precedence over those in /run/ which in turn take precedence over those in /usr/lib/ .

How restart systemd service in Linux?

The next time you boot the system, the service will either start or not start, depending on its default settings. You can use the enable and disable subcommands to manage those defaults. Reboot the system with reboot sudo systemctl reboot , and the service won't automatically start.


1 Answers

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
like image 113
Mark Avatar answered Sep 20 '22 12:09

Mark