Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

Linux Time Command - DesignLinux

Dec 13 2020
designlinux 0 Comments
Linux Time Command

Time command is useful when you want to determine the command execution time. Generally, it’s useful to test the performance of the commands and scripts. In this guide, we will cover how to use the time command in Linux.

When you are writing multiple script which doing same job and want to choose better one by performance, you can use the time command to test the execution time of each script.

Time Command Versions#

The most widely used Linux shells Bash and Zsh have their built-in versions of the time command which is better than the Gnu time command.

Use the type command to determine whether the time is a binary or a built-in keyword.

type time
# Bash
time is a shell keyword

# Zsh
time is a reserved word

# GNU time (sh)
time is /usr/bin/time

In Gnu time command, you need to specify the full path /usr/bin/time to the time binary. Use the env command or use a leading backslash \time which prevents both and built-ins from being used.

You can format the output and show other useful information like memory I/O and IPC calls using the Gnu time.

Using Linux Time Command#

Let’s see an example, to measure the time of download the wordpress using the wget tool:

time wget https://wordpress.org/latest.tar.gz

The output is depends on the version of the time command which your system have:

#Bash
real    0m3.565s
user    0m0.042s
sys     0m0.092s


# Zsh
0.042s user 0.092s system 1% cpu 3.565s total


# GNU time (sh)
0.042user 0.092system 0:03.57elapsed 1%CPU (0avgtext+0avgdata 6060maxresident)k
0inputs+201456outputs (0major+315minor)pagefaults 0swaps

Here,

  • The real or total or elapsed is showing the time which taken from start to wget command completed.
  • user – amount of CPU time spent in user mode.
  • system or sys – It shows the amount of CPU time spent in kernel mode.

Conclusion#

You successfully learned how to use the time command. You can learn more about the Gnu time command by visiting the time man page.

If you have any question or feedback, please leave a comment below.

Related

Tags: terminal, time

How to Redirect stderr to stdout in Bash

Prev Post

How to Fix “W: Some index files failed to download.” Error In Ubuntu

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 0
  • 696
  • 615,068

DesignLinux.com © All rights reserved

Go to mobile version