Kill user


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Kill user
# 1  
Old 02-09-2005
Kill user

I have the below script to kill the user who idle for 180 minutes, it work fine , if I want to have one more checking - if the process is in "Runing" mode not in "Sleep" mode ( ps -aux |grep pid ) , then the process will not be killed ( that mean only kill the "Sleep" mode process ) could suggest how can I modify the script ? thx.


set -x
for user in `who -u | awk '{ print $6":"$7 }' | grep -v "\."| awk -F : '{ print ($1*60)+$2":"$3 }'`
do

time=`echo $user | awk -F ":" '{ print $1 }'`
pid=`echo $user | awk -F ":" '{ print $2 }'`

if [[ $time -gt 180 ]]
then
kill -1 $pid 2 >> /dev/null
fi
# 2  
Old 02-09-2005
This link might help.
# 3  
Old 02-09-2005
thx link is not vaild , could post again , thx.
# 4  
Old 02-09-2005
Seems OK by me.
You could try typing in your browser:
https://www.sun.com/bigadmin/scripts...killLogins.txt
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill all process of Oracle user

Hi folks, I want to kill all process of oracle user and won't kill shell, should i try this? Please confirm. 1st way pgrep -u oracle | sudo xargs kill -9 2nd way killall -u oracle (2 Replies)
Discussion started by: learnbash
2 Replies

2. AIX

How to find out and kill all processes for a user?

Hi! We are using AIX 5.3. Can anyone please guide me to find out all the running processes for a specific user, say ' admin' and also kill them by force. Thanks! atech (9 Replies)
Discussion started by: atechcorp
9 Replies

3. Shell Programming and Scripting

User idle time and kill

Hello.. I have many sleepy users on my Solaris box and need to kill them if they are idle for more than 45 minutes for example...I know who -u gives and the idle time but unable to make a awk line to get the condition perfect. Please help...:wall: (9 Replies)
Discussion started by: wimaxpole
9 Replies

4. Shell Programming and Scripting

Write a scripts to kill idle user for 60 min. & email user list to admin in text file

Folks, I have written one script for following condition by referring some of online post in this forum. Please correct it if I'm missing something in it. (OS: AIX 5.3) List the idle user. (I used whoidle command to list first 15 user and get username, idle time, pid and login time).... (4 Replies)
Discussion started by: sumit30
4 Replies

5. Shell Programming and Scripting

Kill Process not owned by other user

Hi Here is my problem: 1)I am login to unix server through my login id and do SU - xxx 2) Start the script which is running in background I want that other user which login to there id and do SU - yyy(Different user) kill that script. Could you please help me in this. (9 Replies)
Discussion started by: mr_harish80
9 Replies

6. Shell Programming and Scripting

kill all user processes

Hi there, i've been searching all over and i thought i had understood the way i should go to kill all the processes related to a user. But i'm getting more confused then i was. By lunch time i have to make a database backup, and for that all the users shoul logout. The problem is that many users... (4 Replies)
Discussion started by: vascobrito
4 Replies

7. Shell Programming and Scripting

Kill all processes belonging to one user

Hi, Is there a way to kill all processes belonging to one user in one shot? Thanks, Narayan (4 Replies)
Discussion started by: narayanv
4 Replies

8. UNIX for Dummies Questions & Answers

what happens when user does kill 1

what happens when user does kill 1 and kill 0 does the system shutdown (6 Replies)
Discussion started by: santosh149
6 Replies

9. Solaris

kill user session

how do i kill a user session (10 Replies)
Discussion started by: fsmadi
10 Replies

10. AIX

Script allows user to kill other users: I'd like to know HOW...

Hello list, Have a problem that's highlighting gaps in my knowledge; can you assist? We have a script that's tacked onto our trading application which allows branch managers etc. to kill off the sessions of other users at their branch. A menu option in the application spawns a shell running... (8 Replies)
Discussion started by: alexop
8 Replies
Login or Register to Ask a Question