I have enabled and started a user service (
systemctl --user enable serviceName... etc.).
But when I log off, the service stops. Why?
I have made a similar user service on Fedora 22 before, but that doesn't stop when I log off.
Is there any workaround for this?
It might be even better:
The systemd user instance is started after the first login of a user and killed after the last session of the user is closed. Sometimes it may be useful to start it right after boot, and keep the systemd user instance running after the last session closes, for instance to have some user process running without any open session. Lingering is used to that effect. Use the following command to enable lingering for specific user:
# loginctl enable-linger username
Systemd user services only last as long as a user's session does. This means you must be logged in for a user service to operate successfully.
In Ubuntu, your session ends when you log out of X, and all terminals (TTYs, local, and remote). I would assume Fedora kept a user session open for you.
For Ubuntu, I would suggest that you create a system-level service and then tell it to run as a specific user. You can do this by setting
Group= in the
[Service] section of your file. If you want to just have write access on that user account, I would suggest you set appropriate file permissions.
Finally, if you want to make it so that a service starts only when a user tells it to, you can use the instructions from this AU post.