Shell Script to control logins
Hello there this is my first post!!
I need a shell script that checks the time that every user is logged to the machine and when the time expires it would send him a message and logged him out... If anyone could help me............:) :) :) Sorry for my poor english....:( |
You could look at the output from:
who -u and use either the idle time or login time to choose who to log off. |
You can check the output with the w command to get the details regarding what each user is doing right now
|
My problem is that the w or who tells me the time tha each user logged in, not the minutes the user is connected to the machine.
I don't know how to caclulate the time each user is connected. for example i want to disconnect any user when 30 minutes expires. |
Just compare it to the output of "date". Do you want it to be 30 minutes idle time or 30 minutes total time?
|
I want it to be 30 min total time.
I know how to take the logins from who and put them to a file but i don't know how to compare the time that he logged in with current time. I think i must do it with awk but i search the net i see examples but i can't understand how awk works....:( |
I just wrote this of the top of my head but it should work. I suggest you test it first though:
Code:
#!/bin/bash |
Hey,
Why don't we use the command "finger" that shows ideal time and login time .By that we can solve our prob through small shell script!.Bye |
Thanks for the script!!!:)
I have done a few changes and now it is ok. Code:
#!/bin/bash : - 06:3 test_2:line 22:[ : -lt : unary operator expected test_2:line 28:[ : -lt : unary operator expected Killing ikos -3037 ............ line 22,28 are the 2 if but it runs just fine! It should be Killing Nikos -3037 I lose "N" the first character why that??? |
For some reason that "IFS" newline has never worked for me try it back with:
IFS=" " |
All times are GMT -5. The time now is 08:57 AM. |