time command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting time command
# 1  
Old 01-10-2009
time command

time command uses std. error to give its result.
wn we type
$ time cat new\ file 2>/dev/null
its result shd not be printed. but its still being printed..
wts the prob ..??

eg .

[suhaas@localhost ~]$ time cat new\ file
#include<stdio.h>

int main()
{
printf("%d",macro);


}

real 0m0.003s
user 0m0.000s
sys 0m0.001s


[suhaas@localhost ~]$ time cat new\ file >/dev/null

real 0m0.008s
user 0m0.000s
sys 0m0.003s



but now wn im redirecting std. error to null still its result is being printed ..like
[suhaas@localhost ~]$ time cat new\ file 2>/dev/null
#include<stdio.h>

int main()
{
printf("%d",macro);


}

real 0m0.003s
user 0m0.000s
sys 0m0.003s

this last portion shdnt b there if its result is given by std error..but still its there. wts is the reason???

Last edited by suhaas; 01-10-2009 at 02:45 PM..
# 2  
Old 01-10-2009
Quote:
Originally Posted by suhaas
time command uses std. error to give its result.
wn we type
$ time cat new\ file 2>/dev/null
its result shd not be printed. but its still being printed..

Why use time if you don't want its output?

Code:
{ time cat new\ file; } 2>/dev/null

# 3  
Old 01-10-2009
2> only redirects errors to a file.

> will redirect normal output to a file.
# 4  
Old 01-10-2009
@ishkawa
time command as i have earlier said uses std. error to give its output so while im using 2>/dev/null it shouldnt give any out put ..
but thats not the case ,..
n i wanted a reson fr that..

Last edited by suhaas; 01-10-2009 at 04:32 PM..
# 5  
Old 01-10-2009
@cfajohnson
thankx [Smilie]
# 6  
Old 01-10-2009
Time does not use stderr for normal ouput. stderr is for error messages. stdout is for normal output. Time uses stdout to send output unless something goes wrong and it has to send error messages. Then it will send error messages to stderr.

If you use a command like
Code:
time 2> /dev/null

you will still see output sent to stdout but not output sent to sdterr.
# 7  
Old 01-10-2009
{ time ; } 2> /dev/null
check this...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

PS command - TIME column is 00:00:00

Hi, I am running the following command: ps -efk -o "user pid ppid pcpu pmem stime time vsz rssize args" But TIME column is always 00:00:00 . The AIX Actual version is 6.1.8.0 When I run it on another server that I have with version 6.1.0.0, the output is valid. Regards, Amit (6 Replies)
Discussion started by: amitlib
6 Replies

2. Shell Programming and Scripting

Date/Time for command

Hello all, Part of a script I am writing needs to check for a certain date.. example If it is saturday between 1pm and 2pm, kick off this script.../directory/script.sh need some pointers as to what the best way to do this is. (3 Replies)
Discussion started by: jeffs42885
3 Replies

3. AIX

time of a particular command run

Hello all, I need to find, what time a particular command was run in one of our AIX box. In our environment, we use 'powerbroker' to login as root and there are so many people who use this. I tried history command, which shown me similar to below: 406 ls -l | *user* 407 ls -l... (1 Reply)
Discussion started by: gsabarinath
1 Replies

4. Programming

Time Taken to execute a command

How can we find the time taken by a comman to execute say cp a b what is the time taken by this command (2 Replies)
Discussion started by: abhisheklodha13
2 Replies

5. UNIX for Dummies Questions & Answers

Differences between time command and usr/bin/time

I wondered if someone could point out the differences between the time commmand and usr/bin/time and the accuracy one might have over another. Also, is there a website or two a person could maybe link for me to describe the differences? Thank you for your time. (2 Replies)
Discussion started by: icedrake
2 Replies

6. Shell Programming and Scripting

Time Command - Part 2

I am trying to collect some scripts performance. I wrote: #!/usr/local/bin/bash echo Locked Objects time /webaplic/monitor_exp_funcional.sh NUM_LOCKED_OBJ echo Users On time /webaplic/monitor_exp_funcional.sh USERS_ON Then I call "test.sh > Results.out" Obviously, the time command... (4 Replies)
Discussion started by: bdalmeida
4 Replies

7. Shell Programming and Scripting

get only the up time from uptime command

Hi all,:o i am new to shell scripting and i have aproblem like i just want to extractthe uptime of the system from an uptime command which gives the output as the Current time , how long the system has been running,how many users are surrently logged on and the system load averages for past 1,5,... (5 Replies)
Discussion started by: tulip
5 Replies

8. UNIX for Dummies Questions & Answers

ps command - time field

Hi all, Can someone extending on what the time field is explaining in a ps command. Man page only has this: time The cumulative execution time for the process. Is this a combined CPU time? if that is the case then it should be impossible to have a 00:00 time on any process. ... (1 Reply)
Discussion started by: nhatch
1 Replies

9. UNIX for Dummies Questions & Answers

Running two command at the same time

Is there any way I could run two commands at the same time? Say I have in my script a command that grep a keyword from a huge size file: zgrep $KEYWORD $FILE and because this is a large file it takes a while to finish, so I would want that while zgrep is doing its job, I have a function that... (10 Replies)
Discussion started by: Orbix
10 Replies

10. UNIX for Advanced & Expert Users

output of the time command ?

can someone tell me the meaning of this commnad, If you want to see a grand total of CPU time for a program when it finishes running, you can use the time command. At the Unix prompt, enter: time java myprog Replace myprog with the name of the program you are running. The following is an... (2 Replies)
Discussion started by: ldpathak
2 Replies
Login or Register to Ask a Question