6

I need to run my application in screen when specific users are logged out and kill the screen when someone from my user list logged in. So I am thinking about bash script, which will be called periodically from cron and:

  1. Checks if specific users are logged in.
  2. If nobody is logged in - spawn screen and save pid to file or do nothing if pid file already exists
  3. If someone is logged in - read pid from file and kill screen

I am looking for more sophisticated alternatives, which will eliminate periodically running script from cron.

3

Several obvious options:

  1. modify /etc/profile to add a logout hook (or if your system already has a logout hook file, modify that)
  2. modify the system PAM configuration to add an extra session controller (pam_script library specifically addresses this)
  3. modify the login shell of the users under consideration to something which kills your other program on startup, spawns the real login shell, and then launches the screen program when the real login shell exits
  4. (if you only care about console logins) replace getty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.