How to exit from a command after n seconds?

Answer #1 100 %

bash coreutils has got 'timeout` command.

From manual:


Start COMMAND, and kill it if still running after NUMBER seconds. SUFFIX may be "s" for seconds (the default), "m" for minutes, "h" for hours or "d" for days.

for example:

timeout 5 sleep 6

Tags: bashexit

You’ll also like:

© 2023 CodeForDev.com -