How to run a command with a timeout so that it is killed if it exceeds the timeout threshold?

You are probably looking for the timeout command in coreutils. Since it’s a part of coreutils, it is technically a C solution, but it’s still coreutils. info timeout for more details.
Here’s an example:

timeout 5 /path/to/slow/command with options

Leave a Comment