Header Ads Widget

[MAN] time

Content-type: text/html; charset=UTF-8 Man page of TIME

TIME

Section: User Commands (1)
Updated: Debian GNU/Linux
Index Return to Main Contents
 

NAME

time - run programs and summarize system resource usage  

SYNOPSIS

time
[ -apqvV ] [ -f FORMAT ] [ -o FILE ]
[ --append ] [ --verbose ] [ --quiet ] [ --portability ]
[ --format=FORMAT ] [ --output=FILE ] [ --version ]
[ --help ] COMMAND [ ARGS ]
 

DESCRIPTION

time run the program COMMAND with any given arguments ARG.... When COMMAND finishes, time displays information about resources used by COMMAND (on the standard error output, by default). If COMMAND exits with non-zero status, time displays a warning message and the exit status.

time determines which information to display about the resources used by the COMMAND from the string FORMAT. If no format is specified on the command line, but the TIME environment variable is set, its value is used as the format. Otherwise, a default format built into time is used.

Options to time must appear on the command line before COMMAND. Anything on the command line after COMMAND is passed as arguments to COMMAND.

 

OPTIONS

-o FILE, --output=FILE
Write the resource use statistics to FILE instead of to the standard error stream. By default, this overwrites the file, destroying the file's previous contents. This option is useful for collecting information on interactive programs and programs that produce output on the standard error stream.
-a, --append
Append the resource use information to the output file instead of overwriting it. This option is only useful with the `-o' or `--output' option.
-f FORMAT, --format FORMAT
Use FORMAT as the format string that controls the output of time. See the below more information.
--help
Print a summary of the command line options and exit.
-p, --portability
Use the following format string, for conformance with POSIX standard 1003.2:
          real %e
          user %U
          sys %S
-v, --verbose
Use the built-in verbose format, which displays each available piece of information on the program's resource use on its own line, with an English description of its meaning.
--quiet
Do not report the status of the program even if it is different from zero.
-V, --version
Print the version number of time and exit.

 

FORMATTING THE OUTPUT

The format string FORMAT controls the contents of the time output. The format string can be set using the `-f' or `--format', `-v' or `--verbose', or `-p' or `--portability' options. If they are not given, but the TIME environment variable is set, its value is used as the format string. Otherwise, a built-in default format is used. The default format is:
  %Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k
  %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps

The format string usually consists of `resource specifiers' interspersed with plain text. A percent sign (`%') in the format string causes the following character to be interpreted as a resource specifier, which is similar to the formatting characters in the printf(3) function.

A backslash (`\') introduces a `backslash escape', which is translated into a single printing character upon output. `\t' outputs a tab character, `\n' outputs a newline, and `\\' outputs a backslash. A backslash followed by any other character outputs a question mark (`?') followed by a backslash, to indicate that an invalid backslash escape was given.

Other text in the format string is copied verbatim to the output. time always prints a newline after printing the resource use information, so normally format strings do not end with a newline character (or `\n').

There are many resource specifications. Not all resources are measured by all versions of Unix, so some of the values might be reported as zero. Any character following a percent sign that is not listed in the table below causes a question mark (`?') to be output, followed by that character, to indicate that an invalid resource specifier was given.

The resource specifiers, which are a superset of those recognized by the tcsh(1) builtin `time' command, are:

%
A literal `%'.
C
Name and command line arguments of the command being timed.
D
Average size of the process's unshared data area, in Kilobytes.
E
Elapsed real (wall clock) time used by the process, in [hours:]minutes:seconds.
F
Number of major, or I/O-requiring, page faults that occurred while the process was running. These are faults where the page has actually migrated out of primary memory.
I
Number of file system inputs by the process.
K
Average total (data+stack+text) memory use of the process, in Kilobytes.
M
Maximum resident set size of the process during its lifetime, in Kilobytes.
O
Number of file system outputs by the process.
P
Percentage of the CPU that this job got. This is just user + system times divided by the total running time. It also prints a percentage sign.
R
Number of minor, or recoverable, page faults. These are pages that are not valid (so they fault) but which have not yet been claimed by other virtual pages. Thus the data in the page is still valid but the system tables must be updated.
S
Total number of CPU-seconds used by the system on behalf of the process (in kernel mode), in seconds.
U
Total number of CPU-seconds that the process used directly (in user mode), in seconds.
W
Number of times the process was swapped out of main memory.
X
Average amount of shared text in the process, in Kilobytes.
Z
System's page size, in bytes. This is a per-system constant, but varies between systems.
c
Number of times the process was context-switched involuntarily (because the time slice expired).
e
Elapsed real (wall clock) time used by the process, in seconds.
k
Number of signals delivered to the process.
p
Average unshared stack size of the process, in Kilobytes.
r
Number of socket messages received by the process.
s
Number of socket messages sent by the process.
t
Average resident set size of the process, in Kilobytes.
w
Number of times that the program was context-switched voluntarily, for instance while waiting for an I/O operation to complete.
x
Exit status of the command.

 

EXAMPLES

To run the command `wc /etc/hosts' and show the default information:
     time wc /etc/hosts

To run the command `ls -Fs' and show just the user, system, and total time:
     time -f "\t%E real,\t%U user,\t%S sys" ls -Fs

To edit the file BORK and have `time' append the elapsed time and number of signals to the file `log', reading the format string from the environment variable `TIME':
     export TIME="\t%E,\t%k" # If using bash or ksh
     setenv TIME "\t%E,\t%k" # If using csh or tcsh
     time -a -o log emacs bork

Users of the bash shell need to use an explicit path in order to run the external time command and not the shell builtin variant. On system where time is installed in /usr/bin, the first example would become
     /usr/bin/time wc /etc/hosts

 

ACCURACY

The elapsed time is not collected atomically with the execution of the program; as a result, in bizarre circumstances (if the time command gets stopped or swapped out in between when the program being timed exits and when time calculates how long it took to run), it could be much larger than the actual execution time.

When the running time of a command is very nearly zero, some values (e.g., the percentage of CPU used) may be reported as either zero (which is wrong) or a question mark.

Most information shown by time is derived from the wait3(2) system call. The numbers are only as good as those returned by wait3(2). On systems that do not have a wait3(2) call that returns status information, the times(2) system call is used instead. However, it provides much less information than wait3(2), so on those systems time reports the majority of the resources as zero.

The `%I' and `%O' values are allegedly only `real' input and output and do not include those supplied by caching devices. The meaning of `real' I/O reported by `%I' and `%O' may be muddled for workstations, especially diskless ones.

 

DIAGNOSTICS

The time command returns when the program exits, stops, or is terminated by a signal. If the program exited normally, the return value of time is the return value of the program it executed and measured. Otherwise, the return value is 128 plus the number of the signal which caused the program to stop or terminate.  

AUTHOR

time was written by David MacKenzie. This man page was added by Dirk Eddelbuettel <edd@debian.org>, the Debian GNU/Linux maintainer, for use by the Debian GNU/Linux distribution but may of course be used by others.

 

SEE ALSO

tcsh(1), printf(3)


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
FORMATTING THE OUTPUT
EXAMPLES
ACCURACY
DIAGNOSTICS
AUTHOR
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 04:45:28 GMT, September 16, 2022 Content-type: text/html; charset=UTF-8 Man page of TIME

TIME

Section: Linux Programmer's Manual (2)
Updated: 2017-09-15
Index Return to Main Contents
 

NAME

time - get time in seconds  

SYNOPSIS

#include <time.h>

time_t time(time_t *tloc);  

DESCRIPTION

time() returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).

If tloc is non-NULL, the return value is also stored in the memory pointed to by tloc.  

RETURN VALUE

On success, the value of time in seconds since the Epoch is returned. On error, ((time_t) -1) is returned, and errno is set appropriately.  

ERRORS

EFAULT
tloc points outside your accessible address space (but see BUGS).
On systems where the C library time() wrapper function invokes an implementation provided by the vdso(7) (so that there is no trap into the kernel), an invalid address may instead trigger a SIGSEGV signal.
 

CONFORMING TO

SVr4, 4.3BSD, C89, C99, POSIX.1-2001. POSIX does not specify any error conditions.  

NOTES

POSIX.1 defines seconds since the Epoch using a formula that approximates the number of seconds between a specified time and the Epoch. This formula takes account of the facts that all years that are evenly divisible by 4 are leap years, but years that are evenly divisible by 100 are not leap years unless they are also evenly divisible by 400, in which case they are leap years. This value is not the same as the actual number of seconds between the time and the Epoch, because of leap seconds and because system clocks are not required to be synchronized to a standard reference. The intention is that the interpretation of seconds since the Epoch values be consistent; see POSIX.1-2008 Rationale A.4.15 for further rationale.

On Linux, a call to time() with tloc specified as NULL cannot fail with the error EOVERFLOW, even on ABIs where time_t is a signed 32-bit integer and the clock ticks past the time 2**31 (2038-01-19 03:14:08 UTC, ignoring leap seconds). (POSIX.1 permits, but does not require, the EOVERFLOW error in the case where the seconds since the Epoch will not fit in time_t.) Instead, the behavior on Linux is undefined when the system time is out of the time_t range. Applications intended to run after 2038 should use ABIs with time_t wider than 32 bits.  

BUGS

Error returns from this system call are indistinguishable from successful reports that the time is a few seconds before the Epoch, so the C library wrapper function never sets errno as a result of this call.

The tloc argument is obsolescent and should always be NULL in new code. When tloc is NULL, the call cannot fail.  

C library/kernel differences

On some architectures, an implementation of time() is provided in the vdso(7).  

SEE ALSO

date(1), gettimeofday(2), ctime(3), ftime(3), time(7), vdso(7)  

COLOPHON

This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
CONFORMING TO
NOTES
BUGS
C library/kernel differences
SEE ALSO
COLOPHON

This document was created by man2html, using the manual pages.
Time: 04:45:33 GMT, September 16, 2022 Content-type: text/html; charset=UTF-8 Man page of TIME

TIME

Section: GNU Awk Extension Modules (3am)
Updated: Jan 15 2013
Index Return to Main Contents
 

NAME

time - time functions for gawk  

SYNOPSIS

@load "time"

time = gettimeofday()
ret = sleep(amount)  

DESCRIPTION

The time extension adds two functions named gettimeofday() and sleep(), as follows.
gettimeofday()
This function returns the number of seconds since the Epoch as a floating-point value. It should have subsecond precision. It returns -1 upon error and sets ERRNO to indicate the problem.
sleep(seconds)
This function attempts to sleep for the given amount of seconds, which may include a fractional portion. If seconds is negative, or the attempt to sleep fails, then it returns -1 and sets ERRNO. Otherwise, the function should return 0 after sleeping for the indicated amount of time.
 

EXAMPLE

@load "time"
...
printf "It is now %g seconds since the Epoch\n", gettimeofday()
printf "Pausing for a while... " ; sleep(2.5) ; print "done"
 

SEE ALSO

GAWK: Effective AWK Programming, filefuncs(3am), fnmatch(3am), fork(3am), inplace(3am), ordchr(3am), readdir(3am), readfile(3am), revoutput(3am), rwarray(3am).

gettimeofday(2), nanosleep(2), select(2).  

AUTHOR

Arnold Robbins, arnold@skeeve.com.  

COPYING PERMISSIONS

Copyright © 2012, 2013, Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of this manual page provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation.


 

Index

NAME
SYNOPSIS
DESCRIPTION
EXAMPLE
SEE ALSO
AUTHOR
COPYING PERMISSIONS

This document was created by man2html, using the manual pages.
Time: 04:45:40 GMT, September 16, 2022 Content-type: text/html; charset=UTF-8 Man page of TIME.CONF

TIME.CONF

Section: Linux-PAM Manual (5)
Updated: 09/19/2013
Index Return to Main Contents
 

NAME

time.conf - configuration file for the pam_time module  

DESCRIPTION

The pam_time PAM module does not authenticate the user, but instead it restricts access to a system and or specific applications at various times of the day and on specific days or over various terminal lines. This module can be configured to deny access to (individual) users based on their name, the time of day, the day of week, the service they are applying for and their terminal from which they are making their request.

For this module to function correctly there must be a correctly formatted /etc/security/time.conf file present. White spaces are ignored and lines maybe extended with '\' (escaped newlines). Text following a '#' is ignored to the end of the line.

The syntax of the lines is as follows:

services;ttys;users;times

In words, each rule occupies a line, terminated with a newline or the beginning of a comment; a '#'. It contains four fields separated with semicolons, ';'.

The first field, the services field, is a logic list of PAM service names that the rule applies to.

The second field, the tty field, is a logic list of terminal names that this rule applies to.

The third field, the users field, is a logic list of users or a netgroup of users to whom this rule applies.

For these items the simple wildcard '*' may be used only once. With netgroups no wildcards or logic operators are allowed.

The times field is used to indicate the times at which this rule applies. The format here is a logic list of day/time-range entries. The days are specified by a sequence of two character entries, MoTuSa for example is Monday Tuesday and Saturday. Note that repeated days are unset MoMo = no day, and MoWk = all weekdays bar Monday. The two character combinations accepted are Mo Tu We Th Fr Sa Su Wk Wd Al, the last two being week-end days and all 7 days of the week respectively. As a final example, AlFr means all days except Friday.

Each day/time-range can be prefixed with a '!' to indicate "anything but". The time-range part is two 24-hour times HHMM, separated by a hyphen, indicating the start and finish time (if the finish time is smaller than the start time it is deemed to apply on the following day).

For a rule to be active, ALL of service+ttys+users must be satisfied by the applying process.

Note, currently there is no daemon enforcing the end of a session. This needs to be remedied.

Poorly formatted rules are logged as errors using syslog(3).  

EXAMPLES

These are some example lines which might be specified in /etc/security/time.conf.

All users except for root are denied access to console-login at all times:

login ; tty* & !ttyp* ; !root ; !Al0000-2400
      

Games (configured to use PAM) are only to be accessed out of working hours. This rule does not apply to the user waster:

games ; * ; !waster ; Wd0000-2400 | Wk1800-0800
      

 

SEE ALSO

pam_time(8), pam.d(5), pam(7)  

AUTHOR

pam_time was written by Andrew G. Morgan <morgan@kernel.org>.


 

Index

NAME
DESCRIPTION
EXAMPLES
SEE ALSO
AUTHOR

This document was created by man2html, using the manual pages.
Time: 04:45:54 GMT, September 16, 2022 Content-type: text/html; charset=UTF-8 Man page of TIME

TIME

Section: Linux Programmer's Manual (7)
Updated: 2016-03-15
Index Return to Main Contents
 

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 divided 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 behalf of the process (e.g., executing system calls). The time(1) command can be used to determine the amount of CPU time consumed during the execution of a program. A program can determine the amount of CPU time it has consumed using times(2), getrusage(2), or clock(3).  

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) and hwclock(8).  

The software clock, HZ, and jiffies

The accuracy of various system calls that set timeouts, (e.g., select(2), sigtimedwait(2)) and measure CPU time (e.g., getrusage(2)) 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 determined 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 2.4.x, HZ was 100, giving a jiffy value of 0.01 seconds; starting with 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 seconds. Since kernel 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 kernel 2.6.20, a further frequency is available: 300, a number that divides evenly for the common video frame rates (PAL, 25 HZ; NTSC, 30 HZ).

The times(2) 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 constant using sysconf(_SC_CLK_TCK).  

High-resolution timers

Before Linux 2.6.21, the accuracy of timer and sleep system calls (see below) was also limited 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 system calls is no longer constrained by the jiffy, but instead can be as accurate as the hardware 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) 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 using gettimeofday(2), which returns time (in seconds and microseconds) that have elapsed since the Epoch; time(2) provides similar information, but only with accuracy to the nearest second. The system time can be changed using settimeofday(2).  

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 ctime(3), 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), strftime(3), and strptime(3).  

Sleeping and setting timers

Various system calls and functions allow a program to sleep (suspend execution) for a specified period of time; see nanosleep(2), clock_nanosleep(2), and sleep(3).

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), getitimer(2), timerfd_create(2), and timer_create(2).  

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 details, see the description of PR_SET_TIMERSLACK in prctl(2).  

SEE ALSO

date(1), time(1), timeout(1), adjtimex(2), alarm(2), clock_gettime(2), clock_nanosleep(2), getitimer(2), getrlimit(2), getrusage(2), gettimeofday(2), nanosleep(2), stat(2), time(2), timer_create(2), timerfd_create(2), times(2), utime(2), adjtime(3), clock(3), clock_getcpuclockid(3), ctime(3), ntp_adjtime(3), ntp_gettime(3), pthread_getcpuclockid(3), sleep(3), strftime(3), strptime(3), timeradd(3), usleep(3), rtc(4), hwclock(8)  

COLOPHON

This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.


 

Index

NAME
DESCRIPTION
Real time and process time
The hardware clock
The software clock, HZ, and jiffies
High-resolution timers
The Epoch
Broken-down time
Sleeping and setting timers
Timer slack
SEE ALSO
COLOPHON

This document was created by man2html, using the manual pages.
Time: 04:45:56 GMT, September 16, 2022

댓글 쓰기

0 댓글