Differences between time command and usr/bin/time


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Differences between time command and usr/bin/time
# 1  
Old 04-24-2005
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  
Old 04-24-2005
/usr/bin/time is an external command. Invoking it causes a fork and an exec to spawn an additional process. The original bourne shell has almost no built-in commands. Today's shells tend to have a lot of built-in commands. This makes them more efficient. Almost all shells have a built-in time command, but the features vary by shell. The built-in time command is more efficient. Also, what if you want to time a built-in command? The external /usr/bin/time cannot do that. Once you have some built-in commands, you really are forced into needing a built-in time to go with them.

In ksh "time" is a compound command which basicly means it can be applied to pipelines easily. Here is a contrived example. It doesn't make sense to pipe stuff to a sleep process, but it's clear that sleep must take some time. So may example is:
grep root /etc/passwd | sleep 2
I'll time that both ways:
$ /usr/bin/time grep root /etc/passwd | sleep 2

real 0.0
user 0.0
sys 0.0
$ time grep root /etc/passwd | sleep 2

real 0m2.04s
user 0m0.01s
sys 0m0.04s
$

The first case was equivalent to:
{ /usr/bin/time grep root /etc/passwd ; } | sleep 2
while the 2nd was equivalent to:
/usr/bin/time { grep root /etc/passwd | sleep 2 ; }
# 3  
Old 02-24-2009
these cases that u have mentioned , i jus wanted to know the reason , y these external and built in comamands behaved differently ..Smilie
can u throw some lite .. Smilie
n also the command that u have mentioned gives a diffrent result:


[user@acer65 ~]$ /usr/bin/time grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0: operator:/root:/sbin/nologin
0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+201minor)pagefaults 0swaps



wt does "0.00user 0.00system 0:00.00elapsed ?%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+201minor)pagefaults 0swaps "output signify ?????
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

/usr/bin/time Shell Scripting Function

Hello, I have made a Linux Shell Script that downloads 6 files from the Internet and then deletes them. Now i want to use the function "/usr/bin/time" and "bc" to calculate how long the avergate run time for the shell script is. I therefore need to do it 100 times. My shell script code is below: ... (6 Replies)
Discussion started by: solo2
6 Replies

2. Solaris

Which package i need to install for corresponding command: /usr/bin/7za?

Hi friends, I need install a CAM on a lack package cluster Solaris 10 OS Sparc. I read the prequirements, OS is missing 2 pkgs: SUNWtcatu SUNWxwrtl I try add by a OS 10-08 CD, To install SUNWtcatu it also missing SUNWj3rt SUNWj3dev To install SUNWj3rt, it show: Cannot find required... (5 Replies)
Discussion started by: tien86
5 Replies

3. Shell Programming and Scripting

Problem with /usr/bin/cd command

Hi , My shell script doesnt function properly while executing. My shell script has the below mentioned code in it. #!/bin/sh CD="/usr/bin/cd" .. .. $CD / .. .. main intention behind giving the $CD / is to replace the cd command with /usr/bin/cd at the time of program execution. ... (5 Replies)
Discussion started by: raghu.amilineni
5 Replies

4. Solaris

difficult time differences

:rolleyes: Hi, How to take the time diffence between start and finish time from a log file? It is like ..... started at Jun 20 23:20 . . ..... finished at Jun 21 01:40 Tryed so many ways but failed to ger exact way. :confused: Your help will be honoured. Ta........Lokesha (1 Reply)
Discussion started by: Lokesha
1 Replies

5. Shell Programming and Scripting

Date/time differences

A thanks to all ahead of time. I've checked previous posts about this subject and can't find any that quite fit what I need. If I've missed the post could you point me there. When I do an ls -al I get the following output: -rw-r--r-- 1 staff staff 855 July 24 20:05 ... (4 Replies)
Discussion started by: gillr
4 Replies

6. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies

7. UNIX for Dummies Questions & Answers

/usr/bin/time

thanks for your recent post. i have this command /usr/bin/time find /usr -name socket.h -print/usr/bin/time find /usr -name socket.h -print which i have ran on my personal linux machine. I dont know how to interpret this command...does it mean that find the names in the usr directory and print it... (1 Reply)
Discussion started by: BigTool4u2
1 Replies

8. Shell Programming and Scripting

Working out time differences

Hi everyone, I need to be able to write into a ksh script, a function that can look at 2 24 hour time variables and work out the difference between them. e.g job1 runs at 21:00 job2 runs at 01:00 diff = 04:00 hours I would also need negative numbers i.e where job1 runs after job2 ... (1 Reply)
Discussion started by: rik1551
1 Replies
Login or Register to Ask a Question