15

I've read several sources so far. Here are the three options I have encountered:

/etc/systemd/system

/usr/lib/systemd/system

/lib/systemd/system

I was originally putting my service in /lib/systemd/system, and it seems a bunch of other services are in that directory as well. However, it's supposed to be in /etc/systemd/system?? This source never talks about the third option: Where do I put my systemd unit file on Arch Linux?

Also, this tutorial seems to put it in that directory. http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/

Please help clarify for me. Enabling my unit is leading to an error message: "Failed to enable unit: Invalid argument" I hypothesize because the directory is wrong. (I am using Arch Linux)

JobHunter69
  • 940
  • 5
  • 12
  • 22

1 Answers1

14

I use Systemd services to launch "kiosk"-style Pi (running CentOS) systems. Systemd pulls from a few configuration directories, but generally you should put Systemd services in /etc/systemd/system/

There are, of course, some requirements of what must be contained in the service file, but as long as it's in that directory, a sudo systemctl enable foo.service enables that service. If you put your services in that directory and are still encountering errors, check your service file. It should contain at least:

[Unit]
Description=Sample Script Startup

[Service] Type=idle ExecStart=/valid/path/to/an/executable/file

[Install] WantedBy=multi-user.target

The Type and WantedBy attributes may vary, depending on what you're trying to achieve, so read the docs!

muru
  • 72,889