The Archives

  • 27.Mar.13
    Limit running time to a program shell | pfortuny | (0)
    There is no obvious way to specify that a program should run for no longer than x seconds. The following stackoverflow question solves it in a very perlish-way. Define a helper function doalarm: $ doalarm () { perl -e 'alarm shift; exec @ARGV' "$@"; } # define a helper function And you are done. $ doalarm 300 ./my_prog will run for at most 300 seconds.
  • 21.Dec.10
    Limiting resources with limits (1) shell | fernape | (0)
    limits is a FreeBSD's base system utility for displaying and setting system resources limits. To some extent it is equivalent to the limit and ulimit commands. It can set limits for filesize, coredumpsize, maxproc, memoryuse and other parameters. Convenience modifiers like k, m or g for kilobytes, megabytes and gigabytes or s, m, h for seconds, minutes and hours can be used in all cases. limits can be used to achieve three different goals: Set resource limits. For example: $ limits -t 1s ls -R / launches the ls -R command with a cputime limit of 1 second. In general, this is the ...