1

I work for a company that made us to install a software that checks our activity. For this purpose, I created a new user for this purpose only called 'work'. The software is called 'wtcd' and it is a daemon service when I install that and run it manually with systemctl start wtcd when I login to work user and stop it when I log out of this user. And when my working hours end, I log out of this user, stop this service again and login to my personal user.

I gave administrative permissions to work user and is included in sudoer file.

I want to know whether it's possible to do this: When work user only logs in, the command sudo systemctl start wtcd run in background, and when this user logs out, it runs sudo systemctl stop wtcd.

How can I do this? I did only find a way to start it on startup, but nothing to do in the end when logging out.

Thanks in advance

0

1 Answer 1

0

https://unix.stackexchange.com/questions/224992/where-do-i-put-my-systemd-unit-file

The best place to put user unit files: /etc/systemd/user or $HOME/.config/systemd/user but it depends on permissions and the situation.

Put your start and stop commands in ~/.bash_profile and ~/.bash_logout respectively

1
  • I added sudo systemctl stop command in these two files for my main personal user and the source both files, the rebooted my laptop but it started again when I logged in to my personal user
    – Saeed
    Commented May 9, 2020 at 19:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .