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.