Does any one know of an equivalent of the GNU/Linux utility cpulimit for FreeBSD?
I'm not talking about process niceness or setting limits on a user account, but actually limiting the percentage of cpu used by a specific process.
Using the /etc/login.conf file, you can set a limit on max CPU time a process is allowed to consume, but it's not currently possible to limit the percentage of the CPU an individual process uses. (Reference here)
You might be able to accomplish a similar effect by running the process in a jail and limiting the resources for the jail
There is also a new utility, cpuset , which you can use to limit certain processes to certain cpu's.
You can set a CPU limit right in tcsh.
You don't need to actually use any of tcsh's other abilities, just make a man-in-the-middle script like this, and it'll exit along with anything else it calls when the time runs out. You can even name the script to be the same as the other program you want to run, and then have it call that program in turn so everything seems seamless.
#!/bin/tcsh -fb
limit -h cputime 120 # Only allow 120 second of CPU max as an
# an example, but any 31-bit number will due.
youractualapplication.real -youractualswitches $*:q # $*:q will pass any
# command line arguements you start this script with
# onto your actual application so things stay transparent.
The -h means that it will use the hardware to enforce the limit. That was install way back on the 80386 so everything should have it these days. But you can omit the -h to have tcsh limit it through software methods although I can't think of any reason to do so, unless maybe you're running so many bazillions of instances that the hardware gets confused or whatever.