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
actual 0m12.010s
person 0m0.004s
sys 0m0.006s

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 nano
actual 0m1.465s
person 0m0.031s
sys 0m0.006s

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.

time firefox
actual 0m6.784s
person 0m4.962s
sys 0m0.459s

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
actual 3.00
person 0.00
sys 0.00

As you possibly can see this provides us the identical output as if we had run it with the bash shortcut.

Conclusion

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.

Check Command and Script Completion Time for Time Command

Christopher Murray

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

You May Also Like

Calculation Number of Days Between Two Dates

Topic: Delphi Language charlene44 wrote: 18/08/2006 at 15h08 calculation of number of…

Top Benefits of Social Media Marketing

We cannot deny the fact that when it comes to marketing, social…

World of Warcraft Classic: Some Players Use Illegal Tools to Stay Connected

Earlier this week, Blizzard released World of Warcraft Classic. The launch was,…

Crash Team Racing Bientt Back on Ps4!

Activision seems not to have finished with the remastering of the Playstation…