time command usage in sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting time command usage in sh script
# 1  
Old 03-08-2007
time command usage in sh script

how do i get the following type of information when we have a time command in sh script.

0.01user 0.00system 1:32.98elapsed 0%CPU (0avgtext+0avgdata 5360maxresident)k
0inputs+0outputs (342major+0minor)pagefaults 0swaps

I always see the following for the time command
real 0m0.000s
user 0m0.000s
sys 0m0.000s


Pls help me solving this mystery output.

Last edited by kris_search; 03-08-2007 at 03:55 PM.. Reason: particular shell only
# 2  
Old 03-08-2007
That looks like the output of time -p The -p option outputs the 'stderr' output version of time.

It could mean that "time" inside the script is an alias for time -p, for example.
# 3  
Old 03-08-2007
Quote:
Originally Posted by kris_search
how do i get the following type of information when we have a time command in sh script.

0.01user 0.00system 1:32.98elapsed 0%CPU (0avgtext+0avgdata 5360maxresident)k
0inputs+0outputs (342major+0minor)pagefaults 0swaps

I always see the following for the time command
real 0m0.000s
user 0m0.000s
sys 0m0.000s


Pls help me solving this mystery output.
The first version comes from an external time command (e.g., /usr/bin/time); the second is from your shell's built-in time command.
# 4  
Old 03-09-2007
if i run time from
/usr/bin/time

then also i see the output as
real 0m0.000s
user 0m0.000s
sys 0m0.000s

Is there any new executable which i need to download to make it work?
# 5  
Old 03-09-2007
Quote:
Originally Posted by kris_search
if i run time from
/usr/bin/time

then also i see the output as
real 0m0.000s
user 0m0.000s
sys 0m0.000s

Is there any new executable which i need to download to make it work?
Please post the exact command you use, and the exact result. Copy and paste, do not retype anything.

Also, take a look at what versions of time you could be accessing. If your shell is bash, use: type -a time.
# 6  
Old 03-09-2007
sh-3.1$ type -a time
time is a shell keyword
time is /usr/bin/time
time is /bin/time

-------------------------------------
sh-3.1$ time

real 0m0.000s
user 0m0.000s
sys 0m0.000s
------------------------------------
sh-3.1$ which time
/usr/bin/time
# 7  
Old 03-09-2007
sh-3.1$ /bin/time
Usage: /bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
[--portability] [--format=format] [--output=file] [--version]
[--help] command [arg...]

---------------------------------------------------

sh-3.1$ /usr/bin/time
Usage: /usr/bin/time [-apvV] [-f format] [-o file] [--append] [--verbose]
[--portability] [--format=format] [--output=file] [--version]
[--help] command [arg...]
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with speeding up my working script to take less time - how to use more CPU usage for a script

Hello experts, we have input files with 700K lines each (one generated for every hour). and we need to convert them as below and move them to another directory once. Sample INPUT:- # cat test1 1559205600000,8474,NormalizedPortInfo,PctDiscards,0.0,Interface,BG-CTA-AX1.test.com,Vl111... (7 Replies)
Discussion started by: prvnrk
7 Replies

2. Linux

Ps command on cpu usage and time

Hi All, Am very new to Linux and unix ...need below help . need to list of process consuming more than 40% cpu and which are older than 10 days of a particular user .... Thanks V (4 Replies)
Discussion started by: venky456
4 Replies

3. Shell Programming and Scripting

Storage usage over time

Hi every one, im kind new in scripting. i need to write a script that will collect my storage usage (df -k) like every hour and save the max amout and min amout into csv file so over time lest say one month we have the min/max values. Is it possible with awk command ? Any ideas are welcome.:) (4 Replies)
Discussion started by: venus699
4 Replies

4. UNIX for Dummies Questions & Answers

Memory usage per user,percent usage,sytem time in ksh

Let's say i have 20 users logged on Server. How can I know how much memory percent used each of them is using with system time in each user? (2 Replies)
Discussion started by: roy1912
2 Replies

5. AIX

Wait time shows high CPU usage

Hi, I can't seem to make sense of this. My wait time is showing really high but vmstat's and topas are showing normal usage. ps aux USER PID %CPU %MEM SZ RSS TTY STAT STIME TIME COMMAND root 9961810 5680.7 0.0 448 384 - A Dec 16 6703072:12 wait ... (2 Replies)
Discussion started by: techy1
2 Replies

6. UNIX for Advanced & Expert Users

Find memory usage along with time

Hi Guys, I have a script. It calls an executable inside (programmed in C). I will have to find the execution time of that script and amount of memory consumed by that process as well. #!/bin/sh echo "Script starting" echo "executable staring" executable parm1 parm2 parm3 echo... (4 Replies)
Discussion started by: PikK45
4 Replies

7. Shell Programming and Scripting

usage of AWK command under perl script

i have two files as shown below t1.txt: argument1 argu2 argu37 t2.txt: 22 33 44 i want o/p as argument1 22 argu2 33 argu37 44 i am trying to merge two file under perl script using following system("paste t1.txt t2.txt | awk... (3 Replies)
Discussion started by: roopa
3 Replies

8. UNIX for Dummies Questions & Answers

Command to display the space usage (memory usage) of a specific directory.

Hi all, Can you please tell me the command, with which one can know the amount of space a specific directory has used. df -k . ---> Displays, the amount of space allocated, and used for a directory. du -k <dir name> - gives me the memory used of all the files inside <dir> But i... (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

9. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

10. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies
Login or Register to Ask a Question