[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-isp
Subject:    Re: bg proccess limit
From:       Mark Johnston <mjohnston () skyweb ! ca>
Date:       2004-05-10 13:52:44
Message-ID: 200405100852.44320.mjohnston () skyweb ! ca
[Download RAW message or body]

"Coldfade" <coldfade@levkov.com> wrote:
>    i mean limit the background proccesses amount ... i work in a shell
>    providing company but can`t find suitable solution for the BSD
>    platform

This is a Simple Matter of Scripting.  Start with:

ps -x -U $THEUSER | egrep '^[0-9]+ +\?\?'

to find processes owned by THEUSER with no controlling terminal (?? in the TT 
column in ps).  You can use egrep -c to count the processes, then pipe the 
results of the same grep through tail to find some processes to kill off.  
Run that once a minute and you're set.

For a nicer fix, I'd go to Perl or Python - just run ps aux once, store the 
results into a hash of arrays (dictionary of lists) by username, then go 
through that hash/dict, comparing it to your policies, and kill off processes 
that are over the limit.

You could also use ulimit, but that will only let you limit the total number 
of processes (instead of the number of background processes.)  Still, for 
most users, the number of background processes allowed plus two or three will 
be sufficient.

HTH,
Mark
_______________________________________________
freebsd-isp@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-isp
To unsubscribe, send any mail to "freebsd-isp-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic