Previous Table of Contents Next


Module 137
time (csh) / times (sh, ksh)

DESCRIPTION

The internal times command reports the cumulative user and system times. The times reported are for the shell and all processes executed from the shell.


C Shell
The internal csh time command is slightly different from the sh/ksh times command. If a numeric argument is supplied, then the statistics of any program that uses more than this time in seconds are displayed. The statistics are the user, system, utilization percentage, and real times that it required to complete the process. The utilization percentage is derived from adding the user and system time and dividing by the real time.

The output of times is displayed in two columns and two rows. The information for the shell is displayed in row one. The cumulative times for all processes run under the shell are displayed in the second row. The first column represents the user time. The second column represents the system time used. The following display is an example of the output generated by times:

     cj> times
     0m02.25s       3m48.48s
     0m33.50s       2m43.34s

The top left number represents 0 minutes and 2.25 seconds of user time have been used by the shell. The top right number shows that 3 minutes and 48.48 seconds have been used by the shell in system time. The next row reports the time used by all processes run under the shell.


C Shell
The output of the csh time command is as follows:
0.03u 0.10s 0:00 43% 0+73k 11+0io 25pf+0w

COMMAND FORMAT

Following is the general format of the times command.

      times command

C Shell
time command

Arguments

The following argument may be passed to the time command.

command Any executable UNIX command.

The output format can be controlled by setting the time variable. The first value assigned to the time value must be the amount of cpu time which must be used before the time is displayed automatically. The format tags are as follows.


Tag Description

%D Average amount of unshared data space.
%E Elapsed (wall clock) time (mm:ss - mm=minutes, ss=seconds)
%F Number of page faults
%I Number of block input operations
%K Average amount of unshared stack space used in kilobytes
%M Maximum real memory used during executin of the process
%O Number of block output operations
%P Total CPU time (%U+%S) as a percentage of Elapsed time (%E)
%S Number of CPU seconds consumed by the kernel on behalf of the user's process
%U Number of CPU seconds consumed by the user's process outside the kernel
%W Number of swaps
%X Average amount of shared memory used in Kilobytes

The default format for the output of time is

     %U %S %E %P %X+%Dk %I+%Oio %Fpf+Ww

To change this format you use the set command. For example

     set time=(0 "%U user %S sys %E elapsed %P percent")

would display just the %U, %S, %E, and %P values after each command.

RELATED COMMANDS

Refer to the time/timex command described in Module 136.

APPLICATIONS

The times command is used to see how much time you have used as a user process and as a system (kernel) process. Using times can keep you informed of how much CPU time you are requiring to perform your tasks.

The command is used on systems where accounting is enforced and monitored. Many UNIX systems don't enforce any type of departmental accounting and thus many users are not aware of their CPU usage. It may be beneficial for you to check your usage for comparison reasons.

TYPICAL OPERATION

In this activity you use the times command to display your accumulated user and system times. Begin at the shell prompt.

1.  Type times and press Return. The sed command can be used to substitute the output of times into a more readable format. See the sed Typical Operation section for an example.
     cj> times
     0m03.03s     3m49.08s
     0m33.50s     2m43.34s

C Shell
cj> time
0.12u 0.17s 0:02 10% 0+204k 6+0io 44pf+0w

2.  Turn to Module 130 to continue the learning sequence.


Previous Table of Contents Next