Timing jobs with time

Sometimes, you might want to know how long a job takes to complete. You can do so using the time command, which times jobs according to the built-in UNIX timer. As Code Listing 9.9shows, all you have to do is enter time followed by the job you want to time.

To time a job using time:

  • time script
    At the shell prompt, type time, followed by the complete job command. After the command finishes, the system will tell you how long it took, as shown in Code Listing 9.9.

To compare job times with time:

1.
time ls
At the shell prompt, type time followed by a job (here, ls).
2.
time nice -n 19 ls
Then, type time followed by another job. In this example, we're comparing a regular ls command to a nice ls command. As Code Listing 9.9 ...

Get Unix: Visual QuickStart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.