Mac OS X 上的超时命令? [英] Timeout command on Mac OS X?

查看:44
本文介绍了Mac OS X 上的超时命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mac OSx 上是否有超时命令的替代方法.基本要求是我能够在指定的时间内运行命令.

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 10 秒.

This program runs ping for 10s on Linux.

推荐答案

您可以使用

brew install coreutils

然后每当你需要超时时,使用

And then whenever you need timeout, use

gtimeout

...相反.为了解释为什么这里有一个来自 Homebrew 警告部分的片段:

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

注意事项

所有命令都以前缀g"安装.

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

如果你真的需要用它们的普通名称来使用这些命令,你可以从你的 bashrc 向你的 PATH 添加一个gnubin"目录,比如:

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"

此外,如果您添加,您可以使用普通名称访问他们的手册页gnuman"目录也从你的 bashrc 到你的 MANPATH:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆