Loooking for a command similar to time, but exiting if the time exceeds a limit Loooking for a command similar to time, but exiting if the time exceeds a limit unix unix

Loooking for a command similar to time, but exiting if the time exceeds a limit


You can combine time (does the timing) with the timeout utility from coreutils (does the killing).

Example:

$ time timeout 1 sleep 4  Command exited with non-zero status 124  0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 2012maxresident)