You need to use /usr/bin/time (hereinafter referred to as “time”) command to find the system resource usage during of execution of a particular command. The following information can be obtained from the “time” command:
- User time
- System time
- Percent of CPU this command got
- Elapsed time
- Average shared text size
- Average unshared data size
- Average stack size
- Average total size
- Maximum resident set size
- Average resident set size
- Major (requiring I/O) page faults
- Minor (reclaiming a frame) page faults
- Voluntary context switches
- Involuntary context switches
- Swaps
- File system inputs
- File system outputs
- Socket messages sent
- Socket messages received
- Signals delivered
- Page size (bytes)
- Exit status
The above describing the resources utilized by the current process or command and can be obtained by “time” command. It is defined as follows in sys/resource.h
/* taken from OSX/FreeBSD unix */ struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; /* max resident set size */ long ru_ixrss; /* integral shared text memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ long ru_minflt; /* page reclaims */ long ru_majflt; /* page faults */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary context switches */ };
Syntax
The syntax is as follows on Linux:
/usr/bin/time -v command /usr/bin/time -v command arg1 arg2
The syntax is as follows on FreeBSD or OS X unix:
/usr/bin/time -l command /usr/bin/time -l command arg1 arg2
Examples
Let us run host command on Linux to find out the resources utilized by the host command during execution:
$ /usr/bin/time -v host www.cyberciti.biz
Sample outputs:
Fig.01: Determine the duration of execution of a particular command on Linux with resource utilization
Let us run date command on OS X or FreeBSD Unix based system to find out the resources utilized by the date command during execution:
$ /usr/bin/time -l date
Sample outputs:
A note about “/usr/bin/time” and time command
- time is a shell command.
- /usr/bin/time is an external command and provides additional information such as the resources utilized by a particular command.
For more information see man pages ksh(1).
🐧 1 comment so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
On my Debian system, /usr/bin/time doesn’t have the –verbose option, while the one in /usr/bin/X11/time does. YMMV.