World Library  
Flag as Inappropriate
Email this Article

Time (Unix)

Article Id: WHEBN0000576487
Reproduction Date:

Title: Time (Unix)  
Author: World Heritage Encyclopedia
Language: English
Subject: List of Inferno applications, Time (disambiguation), Whereis, History (Unix), Bg (Unix)
Collection: Unix Process and Task Management-Related Software, Unix Sus2008 Utilities
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Time (Unix)

time is a command in the Unix operating systems. It is used to determine the duration of execution of a particular command.

Contents

  • Usage 1
  • User Time vs System Time 2
  • Real Time vs CPU Time 3
  • Method of operation 4
  • See also 5
  • References 6

Usage

To use the command, simply precede any command by the word time, such as:

$ time ls

When the command completes, time will report how long it took to execute the ls command in terms of user CPU time, system CPU time, and real time. The output format varies between different versions of the command, and some give additional statistics, as in this example:

$ time host WorldHeritage.org
WorldHeritage.org has address 207.142.131.235
0.000u 0.000s 0:00.17 0.0%      0+0k 0+0io 0pf+0w
$

time(1) can exist as a standalone program (such as GNU time) or as a shell builtin (e.g. in tcsh or in zsh).

User Time vs System Time

The term 'user CPU time' can be a bit misleading at first. To be clear, the total CPU time is the combination of the amount of time the CPU(s) spent performing some action for a program and the amount of time the CPU(s) spent performing system calls for the kernel on the program's behalf. When a program loops through an array, it is accumulating user CPU time. Conversely, when a program executes a system call such as exec or fork, it is accumulating system CPU time.

Real Time vs CPU Time

The term "real time" in this context refers to elapsed "wall clock" time, like using a stop watch. The total CPU time (user time + sys time) may be more or less than that value. Because a program may spend some time waiting and not executing at all (whether in user mode or system mode) the real time may be greater than the total CPU time. Because a program may fork children whose CPU times (both user and sys) are added to the values reported by the time command, but on a multicore system these tasks are run in parallel, the total CPU time may be greater than the real time.

Method of operation

According to the source code of the GNU implementation of time, most information shown by time is derived from the wait3 system call. On systems that do not have a wait3 call that returns status information, the times system call is used instead.

See also

  • System time
  • Cron process for scheduling jobs to run at a particular time.

References

This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 



Copyright © World Library Foundation. All rights reserved. eBooks from Hawaii eBook Library are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.