NEWBIE CORNER: Can't start systemd service
I have a custom-made service that I want to run.
I've linked the service to /etc/systemd:
sudo ln -s $HOME/foo.service /etc/systemd/system/
But then I get:
[me@here ~]$ systemctl start foo
Failed to start foo.service: Unit foo.service not found.
SOLUTION:
The problem was that I had a typo in my service file's link (the ln command). (The path was convoluted enough for me not to notice despite staring at it a dozen times.) ¦ p I feel so dumb.
Thank you all!
Edited 18 Jul 2020. We only hold this version.
About this post
- Posted
- Archived
- Edited
- Score
- 7 · 74% up
- Kind
- Text
- ID
- htbda6
11 comments
and not a symlink. It may be aliased by symlinking, but it is still have to lead
and
$HOME/foo.serviceis not one of those paths.[1] https://www.freedesktop.org/software/systemd/man/systemd.unit.html
I think this is incorrect.
With
sudo ln -s $HOME/foo.service /etc/systemd/system/there is a link in
/etc/systemd/system, which is in the System Unit Search Path.The file linked to,
$HOME/foo.service, does not need to be in the search paths (neither the System Unit one above or the User Unit one,/etc/systemd/user).For example, my service now runs (I had a link typo), and it's linked in
/etc/systemd/userfrom/home/0x340fa899/Dropbox/utility/backups/systems/evanauth/systemd/, not in the paths:Note that upon enabling the service, it was similarly linked in
~/.config/systemd/user/:Might have different behavior for user services, it is just what man reads for system ones. Otherwise, thanks for your research!
This should help you, if it doesn't work after that, feel free to message me
For third-party reference, I've followed these instructions already (this service works on another distro).
Assuming "message" means "DM", I will DM you.
sudo systemctl daemon-reload?
You are trying starting as a normal user, in that case I recommend using user systemd. Put your unit file in
~/.config/systemd/userand append--userin systemctl command.This was not the problem.
Thank you!
I actually did the latter upon learning it's the more correct way to run user-specific daemons, but the problem was a path typo in my link.
After linking service files correctly in
/etc/systemd/system,systemctlcommands work and find the service.After linking service files correctly in
/etc/systemd/user,systemctl --usercommands work and find the service.Is it better to use
~/.config/systemd/userinstead of/etc/systemd/user? : oWhat you put in /etc/systemd/user can be used by all users in
systemctl --user, while ones in ~/.config is only by the user. I like the latter because I don't need root access at all. I think the former is meant more for admins or packagers.Could it be that you just need to
systemd enable foobeforesystemd start foo?No, this is never necessary and was not the problem.