By default, users cannot set user services to run at boot time. The admin must enable this on an individual basis for each user. If lingering is enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services. Takes one or more user names or numeric UIDs as argument. If no argument is specified, enables/disables lingering for the user of the session of the caller.
loginctl enable-linger $USER loginctl disable-linger $USER
Or alternatively:
touch /var/lib/systemd/linger/$USER rm /var/lib/systemd/linger/$USER
You can show a list of lingering users with:
ls /var/lib/systemd/linger
Or alternatively:
loginctl user-status $USER
To check user lingering status in scripts (programmatically):
loginctl show-user "$USER" --property=Linger | grep -q 'yes'