How to ignore program's output when using /usr/bin/time?

I want to know how long a program running, so I tried "/usr/bin/time ./program > /dev/null". But soon I found it displays program's output to stderr. I tried "/usr/bin/time ./program > /dev/null 2>&1" then, but /usr/bin/time's output not appear. So my question is, how to ignore program's output, and keep time's output.

Thanks a lot.

Answers


Use the -o flag to send the output from time to something else then stderr. For example, if you still want it on screen:

/usr/bin/time -o /dev/tty ./program >/dev/null 2>&1

Or, if you want output on stdout very badly:

/usr/bin/time sh -c './program >/dev/null 2>&1'

or similar. However, now you're also measuring the shell's time to start the process, which may or may not be a problem.


Need Your Help

Background fading-in from the bottom based on a range slider value

javascript jquery html css

I'm not very experienced but what I'm trying to do is this. When the page loads I don't have a background but on the right of the page I have a slider that goes from 1 to 100. I am looking for a wa...

itoa for negative numbers?

assembly mips

Bounty: +50 reputation points for anyone that provides the code to make this subroutine work with negative numbers.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.