I want to benchmark a tool. I am using the usual time command. But if it takes more than 1 hour to run, the tool is clearly too bad, and I want to exit immediately and be notified on the stdout.
You can combine
time (does the timing) with the
timeout utility from coreutils (does the killing).
$ time timeout 1 sleep 4 Command exited with non-zero status 124 0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 2012maxresident)