Writing a script to kill users logged in twice
I'd like to know the best approach at writing a script that will kill users who are logged in twice.
We use linux for our business and the users dont get access to a shell instead they login and go straight to the program. However if for some unforseen instance they lose connection, when they login and go to the program they cant update anything because the process is in use. Is there a way to kill the double logged users more likely by timestamp so I know 8:00 logged in once and 12:00pm i know to kill the 8:00 one because thats the first one. Man I hope I didnt confuse anyone with my question. |
Can't you use "screen" to set up the session to the app? In that case on disconnection they can reconnect to their session?
|
You might want to consider to examine the output of 'ps' command. For example if you do:
> ps -Af | grep "pts\/" You might see 'double' users. I'm sure that there is an option in 'ps' to see start time of the process. |
ps -f|grep <username>
5th field is login time |
sounds harsh, I'd avoid it logging things off summarily like that.
how do they log in? can you not use exec to run the program? or put the program as the shell in the passwd file? or kill all users at midnight? |
There are also the w and who commands.
You should probably only kill login shells with a long idle time. And you should be prepared to get a lot of hate mail from your users. |
Quote:
|
hi, here is my quick-and-dirty solution.
this works in aix - not sure what all the ps options do: Code:
# use who to determine who is logged on more than once: my experirience is that ps displays the most recent login on top so you may need to use tail instead of head. you may need to substitute 'ksh' with whatever program they are running at login. |
All times are GMT -5. The time now is 08:56 PM. |