This is just a short cutdown from: https://unix.stackexchange.com/questions/496982/restarting-systemd-service-only-as-a-specific-user as it is easier than to google everytime.
In the case that one wants to run a service as a specific user, if the application allows, by using systemd it is possible. First you have to activate the linger for the user in question:
loginctl enable-linger username
Now you create the corresponding directory and move your service files into it. In my case this was a noip2.service file. All commands are executed as the normal user.
mkdir -p ~/.config/systemd/user
mv ~/noip2.service ~/.config/systemd/user
systemctl --user daemon-reload
systemctl --user enable noip2.service
systemctl --user start noip2.service
It is important to note, that within the user context there is no multi-user.target. Therefore these have to be changed to default.target.
Sources:
https://wiki.archlinux.org/index.php/Systemd/User#Automatic_start-up_of_systemd_user_instances
https://unix.stackexchange.com/questions/496982/restarting-systemd-service-only-as-a-specific-user
https://gist.github.com/NathanGiesbrecht/da6560f21e55178bcea7fdd9ca2e39b5
Keine Kommentare:
Kommentar veröffentlichen