Register
It is currently Wed Nov 26, 2014 6:43 am

ps aux & kill script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sat Jun 29, 2013 3:17 pm   

Joined: Tue Dec 11, 2007 10:21 pm
Posts: 20
Hello , does anyone has any idee of a script which can use to:

ps aux - grep for proccess and if user has more than 5 proccesses to kill them

ps aux|grep $user $limit
killall -9 -u $user

something like , anyone any ideea or something from where i should start?


Top
 Profile  
 PostPosted: Mon Jul 01, 2013 12:31 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 569
hi,

5 is not much: having an X session already opens more than that :/

Code:
test $(ps -U "$user" | wc -l) -gt 5 && killall -u "$user"


Top
 Profile  
 PostPosted: Tue Nov 05, 2013 8:11 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Better to use pgrep(1) and pkill(1) if you have them installed.

Code:
(( $(pgrep -u "$user" -c 2> /dev/null) > 5 )) && pkill -u "$user"


Looks like a bad idea, though.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP