# time - man(7) - [phpMan]

[_time_(7)](https://www.chedong.com/phpMan.php/man/time/7/markdown)                           Miscellaneous Information Manual                           [_time_(7)](https://www.chedong.com/phpMan.php/man/time/7/markdown)

## NAME
       time - overview of time and timers

## DESCRIPTION
### Real time and process time
       _Real_  _time_ is defined as time measured from some fixed point, either from a standard point in
       the past (see the description of the Epoch and calendar  time  below),  or  from  some  point
       (e.g., the start) in the life of a process (_elapsed_ _time_).

       _Process_  _time_  is defined as the amount of CPU time used by a process.  This is sometimes di‐
       vided into _user_ and _system_ components.  User CPU time is the time  spent  executing  code  in
       user  mode.   System CPU time is the time spent by the kernel executing in system mode on be‐
       half of the process (e.g., executing system calls).  The [**time**(1)](https://www.chedong.com/phpMan.php/man/time/1/markdown) command can be used  to  de‐
       termine the amount of CPU time consumed during the execution of a program.  A program can de‐
       termine the amount of CPU time it has consumed using [**times**(2)](https://www.chedong.com/phpMan.php/man/times/2/markdown), [**getrusage**(2)](https://www.chedong.com/phpMan.php/man/getrusage/2/markdown), or [**clock**(3)](https://www.chedong.com/phpMan.php/man/clock/3/markdown).

### The hardware clock
       Most computers have a (battery-powered) hardware clock which the kernel reads at boot time in
       order to initialize the software clock.  For further details, see [**rtc**(4)](https://www.chedong.com/phpMan.php/man/rtc/4/markdown) and [**hwclock**(8)](https://www.chedong.com/phpMan.php/man/hwclock/8/markdown).

### The software clock, HZ, and jiffies
       The  accuracy  of  various system calls that set timeouts, (e.g., [**select**(2)](https://www.chedong.com/phpMan.php/man/select/2/markdown), [**sigtimedwait**(2)](https://www.chedong.com/phpMan.php/man/sigtimedwait/2/markdown))
       and measure CPU time (e.g., [**getrusage**(2)](https://www.chedong.com/phpMan.php/man/getrusage/2/markdown)) is limited by the resolution of the _software_ _clock_,
       a clock maintained by the kernel which measures time in _jiffies_.  The size of a jiffy is  de‐
       termined by the value of the kernel constant _HZ_.

       The  value of _HZ_ varies across kernel versions and hardware platforms.  On i386 the situation
       is as follows: on kernels up to and including Linux 2.4.x, HZ was 100, giving a  jiffy  value
       of  0.01  seconds;  starting with Linux 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001
       seconds.  Since Linux 2.6.13, the HZ value is a kernel configuration  parameter  and  can  be
       100,  250  (the  default) or 1000, yielding a jiffies value of, respectively, 0.01, 0.004, or
       0.001 seconds.  Since Linux 2.6.20, a further frequency is available: 300, a number that  di‐
       vides evenly for the common video frame rates (PAL, 25 Hz; NTSC, 30 Hz).

       The  [**times**(2)](https://www.chedong.com/phpMan.php/man/times/2/markdown)  system call is a special case.  It reports times with a granularity defined by
       the kernel constant _USER_HZ_.  User-space applications can determine the value  of  this  con‐
       stant using _sysconf(_SC_CLK_TCK)_.

### System and process clocks; time namespaces
       The  kernel  supports  a  range  of  clocks that measure various kinds of elapsed and virtual
       (i.e., consumed CPU) time.  These clocks are described in [**clock_gettime**(2)](https://www.chedong.com/phpMan.php/man/clockgettime/2/markdown).   A  few  of  the
       clocks  are settable using [**clock_settime**(2)](https://www.chedong.com/phpMan.php/man/clocksettime/2/markdown).  The values of certain clocks are virtualized by
       time namespaces; see [**time_namespaces**(7)](https://www.chedong.com/phpMan.php/man/timenamespaces/7/markdown).

### High-resolution timers
       Before Linux 2.6.21, the accuracy of timer and sleep system calls (see below) was  also  lim‐
       ited by the size of the jiffy.

       Since Linux 2.6.21, Linux supports high-resolution timers (HRTs), optionally configurable via
       **CONFIG_HIGH_RES_TIMERS**.  On a system that supports HRTs, the accuracy of sleep and timer sys‐
       tem  calls is no longer constrained by the jiffy, but instead can be as accurate as the hard‐
       ware allows (microsecond accuracy is typical of modern hardware).  You can determine  whether
       high-resolution  timers  are  supported  by  checking  the  resolution  returned by a call to
       [**clock_getres**(2)](https://www.chedong.com/phpMan.php/man/clockgetres/2/markdown) or looking at the "resolution" entries in _/proc/timer_list_.

       HRTs are not supported on all hardware architectures.  (Support is provided on x86, ARM,  and
       PowerPC, among others.)

### The Epoch
       UNIX systems represent time in seconds since the _Epoch_, 1970-01-01 00:00:00 +0000 (UTC).

       A  program  can  determine  the  _calendar_ _time_ via the [**clock_gettime**(2)](https://www.chedong.com/phpMan.php/man/clockgettime/2/markdown) **CLOCK_REALTIME **clock,
       which returns time (in seconds and nanoseconds) that have elapsed since  the  Epoch;  [**time**(2)](https://www.chedong.com/phpMan.php/man/time/2/markdown)
       provides  similar information, but only with accuracy to the nearest second.  The system time
       can be changed using [**clock_settime**(2)](https://www.chedong.com/phpMan.php/man/clocksettime/2/markdown).

### Broken-down time
       Certain library functions use a structure of type _tm_ to  represent  _broken-down_  _time_,  which
       stores  time  value  separated  out into distinct components (year, month, day, hour, minute,
       second, etc.).  This structure is described in [**tm**(3type)](https://www.chedong.com/phpMan.php/man/tm/3type/markdown), which also describes functions that
       convert between calendar time and broken-down time.  Functions for converting between broken-
       down time and printable string representations of the time are described in  [**ctime**(3)](https://www.chedong.com/phpMan.php/man/ctime/3/markdown),  **strf‐**
       [**time**(3)](https://www.chedong.com/phpMan.php/man/time/3/markdown), and [**strptime**(3)](https://www.chedong.com/phpMan.php/man/strptime/3/markdown).

### Sleeping and setting timers
       Various  system calls and functions allow a program to sleep (suspend execution) for a speci‐
       fied period of time; see [**nanosleep**(2)](https://www.chedong.com/phpMan.php/man/nanosleep/2/markdown), [**clock_nanosleep**(2)](https://www.chedong.com/phpMan.php/man/clocknanosleep/2/markdown), and [**sleep**(3)](https://www.chedong.com/phpMan.php/man/sleep/3/markdown).

       Various system calls allow a process to set a timer that expires at some point in the future,
       and optionally at repeated intervals;  see  [**alarm**(2)](https://www.chedong.com/phpMan.php/man/alarm/2/markdown),  [**getitimer**(2)](https://www.chedong.com/phpMan.php/man/getitimer/2/markdown),  [**timerfd_create**(2)](https://www.chedong.com/phpMan.php/man/timerfdcreate/2/markdown),  and
       [**timer_create**(2)](https://www.chedong.com/phpMan.php/man/timercreate/2/markdown).

### Timer slack
       Since  Linux  2.6.28,  it  is  possible to control the "timer slack" value for a thread.  The
       timer slack is the length of time by which the kernel may delay the wake-up of certain system
       calls that block with a timeout.  Permitting this delay allows the kernel to coalesce wake-up
       events, thus possibly reducing the number of system wake-ups and saving power.  For more  de‐
       tails, see the description of **PR_SET_TIMERSLACK **in [**prctl**(2)](https://www.chedong.com/phpMan.php/man/prctl/2/markdown).

## SEE ALSO
       [**date**(1)](https://www.chedong.com/phpMan.php/man/date/1/markdown), [**time**(1)](https://www.chedong.com/phpMan.php/man/time/1/markdown), [**timeout**(1)](https://www.chedong.com/phpMan.php/man/timeout/1/markdown), [**adjtimex**(2)](https://www.chedong.com/phpMan.php/man/adjtimex/2/markdown), [**alarm**(2)](https://www.chedong.com/phpMan.php/man/alarm/2/markdown), [**clock_gettime**(2)](https://www.chedong.com/phpMan.php/man/clockgettime/2/markdown), [**clock_nanosleep**(2)](https://www.chedong.com/phpMan.php/man/clocknanosleep/2/markdown),
       [**getitimer**(2)](https://www.chedong.com/phpMan.php/man/getitimer/2/markdown), [**getrlimit**(2)](https://www.chedong.com/phpMan.php/man/getrlimit/2/markdown), [**getrusage**(2)](https://www.chedong.com/phpMan.php/man/getrusage/2/markdown), [**gettimeofday**(2)](https://www.chedong.com/phpMan.php/man/gettimeofday/2/markdown), [**nanosleep**(2)](https://www.chedong.com/phpMan.php/man/nanosleep/2/markdown), [**stat**(2)](https://www.chedong.com/phpMan.php/man/stat/2/markdown), [**time**(2)](https://www.chedong.com/phpMan.php/man/time/2/markdown),
       [**timer_create**(2)](https://www.chedong.com/phpMan.php/man/timercreate/2/markdown), [**timerfd_create**(2)](https://www.chedong.com/phpMan.php/man/timerfdcreate/2/markdown), [**times**(2)](https://www.chedong.com/phpMan.php/man/times/2/markdown), [**utime**(2)](https://www.chedong.com/phpMan.php/man/utime/2/markdown), [**adjtime**(3)](https://www.chedong.com/phpMan.php/man/adjtime/3/markdown), [**clock**(3)](https://www.chedong.com/phpMan.php/man/clock/3/markdown),
       [**clock_getcpuclockid**(3)](https://www.chedong.com/phpMan.php/man/clockgetcpuclockid/3/markdown), [**ctime**(3)](https://www.chedong.com/phpMan.php/man/ctime/3/markdown), [**ntp_adjtime**(3)](https://www.chedong.com/phpMan.php/man/ntpadjtime/3/markdown), [**ntp_gettime**(3)](https://www.chedong.com/phpMan.php/man/ntpgettime/3/markdown), [**pthread_getcpuclockid**(3)](https://www.chedong.com/phpMan.php/man/pthreadgetcpuclockid/3/markdown),
       [**sleep**(3)](https://www.chedong.com/phpMan.php/man/sleep/3/markdown), [**strftime**(3)](https://www.chedong.com/phpMan.php/man/strftime/3/markdown), [**strptime**(3)](https://www.chedong.com/phpMan.php/man/strptime/3/markdown), [**timeradd**(3)](https://www.chedong.com/phpMan.php/man/timeradd/3/markdown), [**usleep**(3)](https://www.chedong.com/phpMan.php/man/usleep/3/markdown), [**rtc**(4)](https://www.chedong.com/phpMan.php/man/rtc/4/markdown), [**time_namespaces**(7)](https://www.chedong.com/phpMan.php/man/timenamespaces/7/markdown),
       [**hwclock**(8)](https://www.chedong.com/phpMan.php/man/hwclock/8/markdown)

Linux man-pages 6.7                          2023-10-31                                      [_time_(7)](https://www.chedong.com/phpMan.php/man/time/7/markdown)
