It is a easy command that measures… you guessed it, time. It isn’t a clock utility, although. It measures the time taken in working a program or script.
[email protected]:~$ time ./script.sh
I’ll clarify the time command and its output in a minute.
There are a couple of completely different variations of the time utility. Right here we might be wanting on the Bash model, since that is the one you’re almost definitely to come across in your system. There’s additionally a Zsh model and a GNU model.
Let’s keep away from confusion and confirm your model now.
[email protected]:~$ kind time
time is a shell key phrase
In case your output appears to be like like this, that’s excellent. Meaning that you’re utilizing bash. The command performs the identical activity in all its iterations, so should you’re not utilizing bash, concern not, you’ll nonetheless be capable to perceive what is occurring. Nevertheless, it could look fairly completely different.
Utilizing time command
Time command measures the next:
- actual time: whole time elapsed
- person: OS processing in person Mode
- sys: OS processing in kernel mode
It may be used with any command or piped instructions.
Time with a text-based utility
Let’s have a look at an instance with nano. Nano is a terminal primarily based textual content editor. If I begin nano after which promptly exit by way of the applying (Ctrl+X), the output will appear like this:
Time with a GUI utility
This additionally works with a GUI utility. The output might be returned as soon as the applying is exited usually or if an interrupt (CTRL+C) is enter on the terminal.
Conventional GNU Model
As I touched on earlier than, most Linux customers run Bash, which primarily makes use of a shortcut to create human readable content material. You possibly can run the total GNU model through the use of the escape character . It will bypass the built-in shortcut.
This time I’ll simply use sleep command to create a dummy job. The quantity is the period in seconds. Additionally, you will see this mirrored within the output’s actual time.
Notice that as a result of it’s a dummy activity, there isn’t any precise useful resource time dedicated to it.
[email protected]:~$ time sleep 3
0.00person 0.00system 0:03.00elapsed 0percentCPU (0avgtext+0avgdata 1944maxresident)ok
0inputs+0outputs (0major+75minor)pagefaults 0swaps
This output is a bit more tough to learn however it additionally shares some details about RAM utilization that you just may discover useful.
GNU Time -p = (bash) time
The output that you just usually see with the bash model is sort of like an alias to GNU time run with the -p choice.
[email protected]:~$ time -p sleep 3
As you possibly can see this provides us the identical output as if we had run it with the bash shortcut.
Did you take pleasure in our information to the time command? I hope all of the following pointers taught you one thing new.
When you like this information, please share it on social media. In case you have any feedback or questions, depart them beneath. In case you have any recommendations for subjects you’d wish to see lined, be happy to depart these as nicely. Thanks for studying.
Christopher works as a Software program Developer in Orlando, FL. He loves open supply, Taco Bell, and a Chi-weenie named Max. Go to his web site for extra info or join with him on social media.
how to find the execution time of a command in unix,shell script execution time,bash time command output,time command in linux,how to check command execution time in unix,linux time command example,linux system time command,linux time command output