How to start the systemd service after logging in and stop it before the user logs out

I have a Fedora 23 machine.

I have a bash script / file synchronization script that synchronizes my local / home directory with a remote directory (on a NAS machine). I start it manually, but I would like to create a systemd service and make it more flexible, since other people use my computer with their user credentials, I would like to know when the user logged in and started my service after that.

Is there something I can do from my service systemd file or will I need to check this from my code in a script?

My main source of documentation is this link https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html

EDIT: I don't know if this will make his decision easier, but I just need to make sure that I have access to environment variables (like USER) and run it as a service.

+4
source share

Source: https://habr.com/ru/post/1627750/


All Articles