pg

[root@server ~]# timeout --help
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 ord' 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

timeout 10s command
若运行超过10秒,将被强行kill掉
也可带后缀,后缀"s"代表秒(默认值),"m"代表分,"h"代表小时,"d"代表天。

timeout -k 20 10 tail -f ~/log.txt
如果 tail 命令在 10 秒后仍然运行,timeout 命令将在 20 秒后发送一个 kill 信号并结束

替代方案:
https://blog.csdn.net/wq3028/article/details/79384522

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code