TIL: timeout in Bash scripts
Here comes a handy utility:
timeout. As the name suggests, this command adds a timeout to other commands. You specify the time limit you want to wait for a command and if that time passes,timeoutsends a signal to terminate it and exits with non-zero. By default,timeoutsendsSIGTERM, but you can change it with the--signalflag, e.g.timeout --signal=SIGKILL 1s foo.For example,
timeout 1s sleep 5will send theSIGTERMsignal tosleepafter 1 second.
(via)