Home timeout工具限制程序运行时间
Post
Cancel

timeout工具限制程序运行时间

/usr/bin/timeout 工具可以指定时间以限制程序的运行时间,时间到期后,自动发送信号,达到终止或强杀程序的效果。 具体参考man 1 timeout

基本用法 : timeout [OPTION] DURATION COMMAND [ARG]...

一些参数

DURATION
DURATION is a floating point number with an optional suffix: ‘s’ for seconds (the default), ‘m’ for minutes, ‘h’ for hours or ‘d’ for days. A duration of 0 disables the associated timeout.
--preserve-status
exit with the same status as COMMAND,即使用用户指定的运行程序的退出码作为timeout程序本身的退出码
--foreground
when not running timeout directly from a shell prompt,allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out
-k, --kill-after=DURATION
also send a KILL signal if COMMAND is still running this long after the initial signal was sent
-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
This post is licensed under CC BY 4.0 by the author.