Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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