Questions tagged [time]

`time` is a command line utility for running another program and summarizing resource usage

time runs another program and keeps track of how much resources the program has spent. It prints these (normally to stdout) after the program exits.
Basic usage:

time PROGRAM

Additional options (to be specified between time and PROGRAM) allow for redirecting time's output to file (-o filename) optional with appending to that file (-a) and for formatting of the output.

494 questions
183
votes
3 answers

Timezone setting in Linux

I'm setting the timezone to GMT+6 on my Linux machine by copying the zoneinfo file to /etc/localtime, but the date command is still showing the time as UTCtime-6. Can any one explain to me this behavior? I'm assuming the date command should display…
Rahul Dhobi
  • 2,037
  • 3
  • 14
  • 11
114
votes
8 answers

Why is scp so slow and how to make it faster?

I'm trying to copy a batch of files with scp but it is very slow. This is an example with 10 files: $ time scp cap_* user@host:~/dir cap_20151023T113018_704979707.png 100% 413KB 413.2KB/s 00:00 cap_20151023T113019_999990226.png 100% …
laurent
  • 1,868
  • 3
  • 17
  • 22
88
votes
9 answers

How to measure time of program execution and store that inside a variable

In order to find out how long certain operations within a Bash (v4+) script take, I would like to parse the output from the time command "separately" and (ultimately) capture it within a Bash variable (let VARNAME=...). Now, I am using time -f '%e'…
0xC0000022L
  • 16,189
  • 24
  • 102
  • 168
79
votes
2 answers

What units of time does "top" use?

If I issue the "top" command and receive results such as: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 00001 bob 25 0 77380 1212 1200 R 95.8 0.0 89122:13 fee 00002 bob 25 0 77380 1196 1184 R 95.4 0.0 …
Abe
  • 1,681
  • 2
  • 13
  • 8
66
votes
1 answer

Date time in Linux bash

I am trying to display a date time in the form of 07/08/2013 16:52:13 by using command in bash script: dt=`date '+%d/%m/%Y_%H:%M:%S'` which variable is used to populate a CSV file. The only char accepted is "_" (underscore) or "-" between date and…
Henry
  • 827
  • 1
  • 7
  • 4
64
votes
1 answer

How do you time how long a command took to run?

How would you find out how long a running process took to complete? Example: date; dd bs=1m if=/foo of=bar; date ^This example only has 1 second of resolution. Any shell is acceptable.
spuder
  • 17,643
  • 36
  • 91
  • 119
61
votes
4 answers

Why does Unix time start at 1970-01-01?

Why does Unix time start at 1970-01-01? Why not 1971-01-01 or any other date?
Templar
  • 823
  • 1
  • 6
  • 13
60
votes
2 answers

Run a command for a specified time and then abort if time exceeds

I want know how I can run a command for a specified time say, one minute and if it doesn't complete execution then I should be able to stop it.
nikhil
  • 992
  • 2
  • 10
  • 16
51
votes
4 answers

Why real time can be lower than user time

I have a script converting video files and I run it at server on test data and measure its time by time. In result I saw: real 2m48.326s user 6m57.498s sys 0m3.120s Why real time is that much lower than user time? Does this have any…
kobylecki
  • 613
  • 1
  • 5
  • 8
40
votes
4 answers

How can I time a pipe?

I want to time a command which consists of two separate commands with one piping output to another. For example, consider the two scripts below: $ cat foo.sh #!/bin/sh sleep 4 $ cat bar.sh #!/bin/sh sleep 2 Now, how can I get time to report the…
terdon
  • 234,489
  • 66
  • 447
  • 667
37
votes
4 answers

get elapsed time in bash

I would like to do the following at one point in a script: start_time=date and this after a process or processes have run: end_time=date and then do this: elapsed=$end_time-$start_time echo "Total of $elapsed seconds elapsed for process" How…
Oliver Williams
  • 1,325
  • 2
  • 14
  • 21
30
votes
1 answer

Why does echo >file use more real time than echo | sed >file?

The example, below, surprised me. It seems to be counter intuitive... aside from the fact that there is a whisker more user time for the echo | sed combo. Why is echo using so much sys time when it runs alone, or should the question be, How does…
Peter.O
  • 32,426
  • 28
  • 115
  • 163
29
votes
6 answers

How to average time commands?

I am timeing some of my commands. Now to average the measures, I'd like to run and time my commands a specified number of times, and get the results with a calculated mean and standard deviation. The result would be like: avgtime -n 100…
Didier Trosset
  • 1,251
  • 1
  • 11
  • 13
28
votes
1 answer

These two Bash lines are functionally equivalent. Can someone explain why one is faster?

$ time if [[ $dir2 -ot $dir1 ]] ; then open $dir2 ; else open $dir1 ; fi real 0m0.055s user 0m0.023s sys 0m0.018s $ time [[ $dir2 -ot $dir1 ]] && open $dir2 || open $dir1 real 0m0.000s user 0m0.000s sys 0m0.000s At above, I…
cp10111
  • 297
  • 3
  • 4
28
votes
1 answer

Why does "ls *" take so much longer than "ls"?

I have a couple of files in a directory: $ ls | wc -l 9376 Can anybody explain why there is such a huge time difference in using ls * and ls? $ time ls > /dev/null real 0m0.118s user 0m0.106s sys 0m0.011s and $ time ls * > /dev/null real…
Sebastian
  • 8,677
  • 4
  • 39
  • 49
1
2 3
32 33