Re: bg proccess limit

From: Mark Johnston (mjohnston_at_skyweb.ca)
Date: 05/10/04

  • Next message: Andre Fortin: "(no subject)"
    To: freebsd-isp@freebsd.org
    Date: Mon, 10 May 2004 08:52:44 -0500
    
    

    "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"


  • Next message: Andre Fortin: "(no subject)"

    Relevant Pages

    • SUMMARY: Why does ksh coredump on kill -0 ?
      ... Thanks to Kris Smith, Roberto Romani, Bob Vickers and Dr Thomas Blinn for their helpful answers. ... it causes the shell to dump core. ... Betreff: Re: Why does ksh coredump on kill -0? ...
      (Tru64-UNIX-Managers)
    • Asynchronous problem
      ... I am trying to shell a program as so ... This works fin but then I want to kill its temp file once it is finished. ... delay is not working properly. ...
      (microsoft.public.word.vba.general)
    • Re: Redirecting output from "kill" command?
      ... that's written to stderr by the parent shell whose child has been killed, ... not by the kill command itself. ... Pid 25165 is the parent shell, pid 25797 is the sleep process which we ...
      (comp.unix.misc)
    • Re: External Unix programme - time limit
      ... checking if the process is still active after the sleep. ... >> kill the right programme...and when using the syntax you ... > You don't need to know the PID, %1 is the first job running in the ... > shell, which should be your ./senkin.e program. ...
      (comp.soft-sys.matlab)