5

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?

1 Answers1

7

The timeout command will do this for you, i.e.

timeout 10s command

It 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.

marinus
  • 1,876
  • 13
  • 11