You are not logged in.
Hi there, I'm trying to get a program to run automatically on login using systemd --user
this is the service file:
$ cat ~/.config/systemd/user/foo.service
[Unit]
Description=foo
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=foo
[Install]
WantedBy=multi-user.targetthe service is enabled:
$ systemctl --user is-enabled foo
enabledafter logging in over ssh the service is neither already loaded nor in the course of starting up, and I don't get an error message:
$ systemctl --user status foo
foo.service - foo
Loaded: loaded (/home/user/.config/systemd/user/foo.service; enabled; vendor preset: enabled)
Active: inactive (dead)manually running the service works:
$ systemctl --user start foo
$ systemctl --user status foo
foo.service - foo
Loaded: loaded (/home/user/.config/systemd/user/foo.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-11-19 20:54:15; 1min 22s ago
Main PID: 457 (java)
CGroup: /user.slice/user-1000.slice/user@1000.service/foo.service
└─457 fooEventually, I'll want the service to run upon boot and not just when the user is logged in, so I already enabled lingering (though I don't think this has anything to do with my current problem
loginctl enable-linger userLast edited by Archlinuxomane (2019-11-20 06:41:05)
Offline
network-online.target is a system target I do not believe there is an equivalent user target.
As the target is never reached the Wants and After requirements are never true so the service does not start.
Offline
Thanks for the info! I reused a service file I found on the net which was meant for "regular" (non-user) systemd and didn't realize that I didn't need the targets. Still, even when I remove the wants/after lines, the service doesn't start.
Last edited by Archlinuxomane (2019-11-19 20:43:02)
Offline
See `ls /usr/lib/systemd/user/*.target` what if you replace multi-user.target with default.target or basic.target?
You may have to clean up the symlinks.
Offline
Yeah, you need to have WantedBy=default.target and make sure the symlink exists in ~/.config/systemd/user/default.target/ after reinstalling the service.
Offline
It works! There was no multi-user.target in /usr/lib/systemd/user/ so I switched to default.target, reenabled the service and now it's starting up on boot.
Thanks everyone!
Offline