Thursday, August 22, 2013

Kill Users Script

I use HP-UX11 
how can i build a script to kill users who stay more than 1 hour ,and this 
script will execute every 2hour
use crontab -e to run the script regularly. Do a man crontab for info.
You do not need to write a script there exists an system variable called TMOUT which you can set in the /etc/profile file. Example 
TMOUT=1800 
export TMOUT 
This will automatically log out any user who is inactive for 1800 seconds or 30 minutes. Note that this only works if the default shell for the user is ksh. Otherwise you will need to write a script and place it in the crontab for root: 
00 0,2,4,6,8,10,12,14,16,18,20,22 * * * /root/NameOfKillScript.sh > /tmp/kill.log 2>&1 

You will need to use the whodo command in your script and read the idle time. Once you have the idle time compare that value to your 1 hour value. If true then perform a "kill -9 PID" otherwise move on to next line in the whodo command.


More Information:




0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM