Sometimes when I write code I found that I made a stupid mistake and some loop takes almost all CPU time forever. Is there a way the running time of a program for example to 10 seconds in bash?
How to limit the running time of a program?
limit
The timeout command will do this for you, i.e.timeout 10s commandIt will kill command after 10 seconds. Instead of s for seconds, you can also use m for minutes, h for hours or d for days. 