Timeout command on Mac OS X?

后端 未结 5 1970
长发绾君心
长发绾君心 2020-12-13 05:29

Is there an alternative for the timeout command on Mac OSx. The basic requirement is I am able to run a command for a specified amount of time.

e.g:

         


        
5条回答
  •  悲&欢浪女
    2020-12-13 06:06

    You can use

    brew install coreutils
    

    And then whenever you need timeout, use

    gtimeout
    

    ..instead. To explain why here's a snippet from the Homebrew Caveats section:

    Caveats

    All commands have been installed with the prefix 'g'.

    If you really need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
    

    Additionally, you can access their man pages with normal names if you add the "gnuman" directory to your MANPATH from your bashrc as well:

    MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"
    

提交回复
热议问题