超时执行持续时间而不是命令

时间:2018-09-05 13:18:03

标签: bash docker sh

我在bash脚本中有一个函数,该函数正在执行以下操作:

get_repo_master_hash() {
    timeout 60 bash -c "git ls-remote $REPOURL | grep refs/heads/master | cut -f 1"
}

但是在我的脚本中执行此操作后,我收到以下消息:

timeout: can't execute '60': No such file or directory

为什么执行持续时间而不是我的命令?

此脚本正在使用alpine / git:1.0.4作为映像的docker容器中执行。

1 个答案:

答案 0 :(得分:1)

在Docker alpine:3.6容器上,我得到了

$timeout --help
Usage: timeout [-t SECS] [-s SIG] PROG ARGS

因此,您应该改为使用timeout -t 60