Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Timeout command on Mac OS X?

Tags:

macos

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.

e.g:

timeout 10 ping google.com 

This program runs ping for 10s on Linux.

like image 303
sheki Avatar asked Aug 17 '10 16:08

sheki


People also ask

What is timeout command?

The “timeout” allows the user to execute a command and then terminate it after a set time has passed.


1 Answers

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" 
like image 153
kvz Avatar answered Sep 21 '22 21:09

kvz