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.10 shows, all you have to do is enter time followed by the command you want to time.

Code Listing 9.10. Enter time plus the full job command to find out the job time.
[ejr@hobbes running]$ time slowscript
0.05user 0.06system 0:50.12elapsed 0%CPU
[ejr@hobbes running]$ time ls
bigdog.tar.gz  slowscript testing.gif
0.03user 0.00system 0:00.03elapsed 78%CPU
[ejr@hobbes running]$ time nice -19 ls
bigdog.tar.gz  slowscript testing.gif
0.03user 0.03system 0:00.06elapsed 93%CPU
[ejr@hobbes running]$ time -p nice -n 19 ls foo real 0.00 user 0.00 sys 0.00 ...

Get Unix Third Edition: 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.