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:
- 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.
time script
To compare job times with time:
1. | time ls |
2. | time nice -n 19 ls |
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.