【问题标题】:Timeout executing duration instead of command超时执行持续时间而不是命令
【发布时间】:2019-02-10 15:49:43
【问题描述】:

我在 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 容器中执行。

【问题讨论】:

  • 添加type timeout 的输出以及有关您问题所用操作系统的信息。
  • @Cyrus type timeout 的输出是 timeout is /usr/bin/timeout。在最初的问题中,我已经用操作系统上运行的命令对其进行了更新。

标签: bash docker sh


【解决方案1】:

在我得到的 Docker alpine:3.6 容器上

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

所以你应该改用timeout -t 60。

【讨论】:

    猜你喜欢
    • 2022-01-08
    • 2020-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    相关资源
    最近更新 更多