timeout 1 sleep 10
echo $?
# sleep 10초를 하지만 1초 있다가 종료하는 것 확인가능
# 그리고 종료 코드가 124 가 나오면 타임아웃되어 종료되었다는 뜻이고, 그외 값은 타임아웃 전 정상종료 시 해당 명령의 종료코드가 나옴
Usage: timeout [OPTION] NUMBER[SUFFIX] COMMAND [ARG]...
or: timeout [OPTION]
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.
Mandatory arguments to long options are mandatory for short options too.
-s, --signal=SIGNAL
specify the signal to be sent on timeout.
SIGNAL may be a name like `HUP' or a number.
See `kill -l` for a list of signals
--help display this help and exit
--version output version information and exit
If the command times out, then exit with status 124. Otherwise, exit
with the status of COMMAND. If no signal is specified, send the TERM
signal upon timeout. The TERM signal kills any process that does not
block or catch that signal. For other processes, it may be necessary to
use the KILL (9) signal, since this signal cannot be caught.
Report timeout bugs to [email protected]
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
For complete documentation, run: info coreutils 'timeout invocation'