Hi,
systemd based system have the ability to start user processes in background and as daemon even the user isn’t logged on to the system.
Instead of defining a system systemd unit which switches the user at process start time, for example
[Service]
...
User=michael
Group=michael
systemd user units can also be started and stopped by the user itself.
You just have to create a systemd unit.
michael@debdev ~# mkdir -p $HOME/.config/systemd/user michael@debdev ~# vi $HOME/.config/systemd/user/myprocess.service
Content of myprocess.service is like
[Unit]
Description=My Process
After=multi-user.target
[Service]
RemainAfterExit=True
ExecStart=/home/michael/bin/myProcess
[Install]
WantedBy=default.target
Important is the WantedBy=default.target option!
Enable the unit and start it
michael@debdev ~# systemctl --user enable myprocess.service michael@debdev ~# systemctl --user start myprocess.service
If you want to start the unit at boot time you have to enable linger for the user.
root@debdev ~# loginctl enable-linger michael
Michael PuTTY Advanced download