kill crashed out users


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting kill crashed out users
# 1  
Old 08-25-2006
kill crashed out users

Hi all,

We have a problem where we get a fair few users either exiting incorrectly or crashing. I'm trying to get a script together that runs every hour to kill these processes off.

We are running Sco OperServer(TM) Release 5

The command we use to get a list of users who have crashed:
ps -ef | grep " 1" | grep "\-sh"
# ps -ef | grep " 1" | grep "\-sh" | cut -c10-15
root 2945 1 0 07:45:38 tty05 00:00:00 -sh
ben 7259 1 11 09:07:14 ttyp68 00:00:00 -sh
bill 8059 1 11 09:16:15 ttyp71 00:00:00 -sh
bob 8553 1 11 09:30:15 ttyp3 00:00:00 -sh

Obviouly to get the pid:
# ps -ef | grep " 1" | grep "\-sh" | cut -c10-15
2945
4184
5829
7259
8059
8553

The problem I have is the PID can be 4 or 5 numbers. Hence when the PID has 4 numbers their is a space before and cannot use kill $i in a for loop. Is their a better way of doing this or is their a way of stripping the space if their is one??

Thank
# 2  
Old 08-25-2006
Use awk to print out column 2 in stead of bitwise cut.

ps -fe | grep "1" | grep "\-sh" | awk '{print $2}'

will do the trick. You can also use the output from that statement in xargs to eliminate the loop you are referring by

ps -fe | grep "1" | grep "\-sh" | awk '{print $2}' | xargs kill -9
# 3  
Old 08-25-2006
Thanks that works fine Smilie

Last edited by tez; 08-25-2006 at 10:36 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

2. UNIX for Advanced & Expert Users

How to kill network users?

Hi everybody. I am using SCO open server. My problem is to kill users logged in my local network. I am using Kill -9 command for kill the repective user/terminal. But it shows in 'who -u'. when i try to kill agina that process it shows like "6229: no such process " User count is... (6 Replies)
Discussion started by: sanjaykunjam
6 Replies

3. AIX

command to kill all loged in users

Guy's I'm looking for command to kill all the loged in users in AIX server Is there specific command can help us to kill any loged in users I have this command who -u it'll show me the process ID of all the users but I want command to kill all the users including to root without... (1 Reply)
Discussion started by: Mr.AIX
1 Replies

4. HP-UX

kill idle users

Hi, In my network we uses the NetTerm program to connect us to HP-UX 10.x server from windows workstations, but in some cases the user doesn't logout and close it by window's x button. The problem is that in HP-UX the user and all his tasks remain active and when he enter again HP-UX creates a... (12 Replies)
Discussion started by: efrenba
12 Replies

5. 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

6. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies

7. HP-UX

Is there a script available to kill Idle users

My max user parm is set to 1050. I'm currently at 1038 this is causing major slow downs on the server. I looking for a way log off "idle" user logins with out having to do it individually. :confused: (5 Replies)
Discussion started by: rfmurphy_6
5 Replies

8. Shell Programming and Scripting

Kill users

Someone knows how do I kill a login user only with the login_name? This moment I kill the user using the following command. E4500:/mg98/samuel$ whodo samuel Tue Sep 14 08:32:10 EST 2004 sun pts/234 samuel 7:30 pts/234 24200 0:00 ksh pts/234 26724 0:00 whodo... (3 Replies)
Discussion started by: samuel
3 Replies

9. Shell Programming and Scripting

kill process of other users

Hi, Can I kill process submitted by another uesr (say user1) if I'm not the su. If I got some previledges granted from user1, can I kill user1's process? Please advise? Thank you very much! Regards, Tse (4 Replies)
Discussion started by: tsesukfan
4 Replies

10. Shell Programming and Scripting

Script to kill stranded/orphan process by users.

I have customers on our AIX/UNIX node startup a process that becomes stranded or orphaned and must be killed. I would like to create a script to check for these orphan processes and kill them. I can have cron run this job. The customers process will run and after 24 hours time out leaving an... (4 Replies)
Discussion started by: rjohnson
4 Replies
Login or Register to Ask a Question