Mac OS X上的超时命令? [英] Timeout command on Mac OS X?
问题描述
在Mac OSx上是否可以使用timeout命令.基本要求是我能够在指定的时间内运行命令.
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.
例如:
timeout 10 ping google.com
此程序在Linux上ping 10s.
This program runs ping for 10s on Linux.
推荐答案
您可以使用
brew install coreutils
然后每当您需要超时时,使用
And then whenever you need timeout, use
gtimeout
..相反.要解释为什么这是自制"警告中的摘录:
..instead. To explain why here's a snippet from the Homebrew Caveats section:
注意事项
所有命令都已安装前缀"g".
All commands have been installed with the prefix 'g'.
如果您确实需要使用这些命令的常规名称,则可以 可以从bashrc中将"gnubin"目录添加到PATH中,例如:
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"
此外,如果添加,则可以使用普通名称访问其手册页 以及从bashrc到MANPATH的"gnuman"目录:
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"
这篇关于Mac OS X上的超时命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!