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

learn more… | top users | synonyms

25
votes
1answer
2k views

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 ...
24
votes
1answer
1k views

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 ...
20
votes
3answers
9k views

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?
18
votes
1answer
2k views

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.
16
votes
3answers
32k views

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 ...
15
votes
2answers
553 views

Is there something like `time` that also records I/O and CPU?

I can pretty quickly monitor the running time of a process with time: x@y ~ $ time foo real 0m14.299s user 0m4.770s sys 0m0.440s Is there a way I can get the same data for ...
14
votes
2answers
8k views

How to run time on multiple commands AND write the time output to file?

I want to run time command to measure time of several commands. What I want to do is: Measure the time of running of all of them added together Write the time output to a file Write the STDERR from ...
12
votes
4answers
2k views

Make bash use external `time` command rather than shell built-in

How can I make bash use time binary (/usr/bin/time) by default instead of the shell keyword? which time returns /usr/bin/time type time returns time is a shell keyword Running time is obviously ...
11
votes
2answers
17k views

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 ...
10
votes
2answers
954 views

How can I redirect `time` output and command output to the same pipe?

Suppose I have a binary called foo. If I want to redirect the output of foo to some other process bar, I could write ./foo | bar. On the other hand, if I wanted to time foo, and redirect the output ...
10
votes
1answer
1k views

Measuring disk I/O usage of a program

time is a brilliant command if you want to figure out how much CPU time a given command takes. I am looking for something similar that can measure the disk I/O of the program and any children. ...
10
votes
3answers
2k views

What is the recommended way to synchronize time using NTP?

This question has come up a number of times in a localized way, this question is meant to provide the preferred/best method for synchronizing a system's clock using NTP. The solution should handle ...
9
votes
8answers
24k views

How to check if NTPD updates machine's time successfully using shell?

I'm trying to use NTPD to update my Linux machine's time to a specified NTP server. Here is the scenario: Each time the Linux machine starts up, I want to update the time from NTP server and if ...
9
votes
2answers
4k views

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 ...
8
votes
2answers
776 views

Measuring time within a script

This thread shows how to measure the time it takes to run a script. In my case, I am interested in measuring time between two points within a script. Here is an example of how I would like to use ...
8
votes
2answers
688 views

Temporarily change time

I need to test aspects of my software that only happen at certain times of the day. Rather than waiting whole days (and getting here at 2:00 AM), I'd like to change the time. But I'd rather not ...
8
votes
2answers
120 views

How can I conditionally pass a subshell through 'time'?

I have a setup script for a Vagrant box where I used to measure single steps with time. Now I would like to conditionally enable or disable the time measurements. For example, previously a line would ...
8
votes
4answers
638 views

Forcing an 'added' alias to every command

Is it possible to forcibly add a timing alias (for lack of a better way to phrase it) to every command in bash? For example, I would like to have a specific user who whenever a command is run, it is ...
8
votes
1answer
3k views

Is there a way to adjust the formatting of the date/time in the GNOME 3 login screen and desktop?

I'm specifically looking to change the formatting in two places: On the desktop, the date/time reads "Sat 21:05". I would like it to read "23-Jul-11 21:05" or "23 Jul 11 21:05". In other words, I ...
7
votes
2answers
97 views

How can other processes affect measurements made with `time`?

If I time a process using the time command, I get output for 'real', 'user', and 'sys'. My understanding from this discussion is that 'real' is wall time, whereas 'user' and 'sys' are process time. ...
7
votes
3answers
4k views

Why is my EC2 server's time off by ~10 seconds every day?

I have what I believe is a system file, /etc/cron.daily/ntpupdate which runs ntpdate ntp.ubuntu.com daily to sync with the network time. Every day it generates output very similar to this: ...
7
votes
3answers
825 views

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 ...
7
votes
1answer
87 views

Time all executions in bash [duplicate]

Is there a way to run all commands in bash as if they were invoked with time in front? I want that I could type $ some_command and this will actually invoke $ time some_command.
6
votes
5answers
3k views

Convert linux sysuptime to well format date

I want to display /proc/uptime in well format as: DD:HH:MM:SS /proc/uptime give me up time of system in seconds, is there a standard solution that convert seconds to this format?
6
votes
1answer
994 views

Why bash time is more precise then GNU time?

The buitin bash command time gives milisecond precision of execution and GNU time (usually /usr/bin/time) gives centisecond precision. The times(2) syscall gives times in clocks, and 100 clocks = 1 ...
6
votes
1answer
1k views

Why would the “real” time be much higher than the “user” and “sys” times combined?

I execute and time many commands (i.e. nslookup) through SSH and I collect the total time needed for the implied service to complete (i.e. DNS). So I collect the user and sys time as the real time ...
6
votes
2answers
7k views

Good method to compare time?

I need to check for the current time and abort the script if it is not proper time of day I am supposed to run it. Also, if anyone else runs it, it should abort. For example: I need my script to only ...
5
votes
2answers
730 views

how does time command work

So when I type time <some_program> I have nice CPU time measurement. But exactly how is this achieved? Also does this have any performance impact on the some_program?
5
votes
1answer
2k views

Increase %e precision with /usr/bin/time shell command

When I run the time command in shell time ./myapp I get an output like the following: real 0m0.668s user 0m0.112s sys 0m0.028s However,when I run the command \time -f %e ./myapp I lose ...
5
votes
3answers
1k views

How can I profile a shell script?

I have several programs that i'm executing in a shell script: ./myprogram1 ./myprogram2 ... I know that I can profile each individual program by editing the sourcecode, but I wanted to know if ...
5
votes
2answers
719 views

How to get the time of several commands with a loop

I have this command: time -p sh -c 'command1; command2;' So command1and command2 is executed and I get the real, user and sys time printed on the console. But I want that command1; command2; is ...
5
votes
2answers
176 views

NTP tool for showing deviance to a certain server

I am searching for a command-line that allows me to check the system time deviance to a NTP server specified on the command-line. I don't want to change/adapt the system time - only displays the ...
5
votes
3answers
15k views

Timezone setting in Linux [closed]

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 ...
5
votes
2answers
137 views

How to report time and other information on all bash commands? [duplicate]

Most of the things I run in the terminal take a long time to compute and I would like to have bash output a time report at the end of every command entered into the terminal. Is there something I can ...
4
votes
2answers
2k views

How do I time a specific command?

(The linux equivalent of TimeThis.exe) Something like: timethis wget foo.com Receiving foo.com ... wget foo.com took 3 seconds.
4
votes
4answers
368 views

Can I write the output the of time difference command to a file?

Can I write the output of the time difference command to a file? For example, I tried: $ time foo.sh > bar.txt But it only gives the output of foo.sh to bar.txt.
4
votes
3answers
1k views

Disable daylight saving time in Debian Linux

I do not want my system to use daylight saving time. root@ali-debserver:~# cat /etc/timezone Asia/Tehran root@ali-debserver:~# cat /etc/default/rcS # # /etc/default/rcS # # Default settings for the ...
4
votes
2answers
2k views

/etc/shadow date of last password change—UTC or local time?

man 5 shadow gives the following description of the third field in each line: The date of the last password change, expressed as the number of days since Jan 1, 1970. The value 0 has a ...
4
votes
1answer
446 views

Querying the current time of a city from terminal

I have friends all over the globe and before calling them I need to know their current time. Is there an application in Linux where one can query a city (if exists) in terminal (something like this): ...
4
votes
4answers
4k views

How to make an Ubuntu time zone change stick?

I'd like to reset the timezone through editing /etc/timezone. However, after I am done editing and save the file, the system time would not change accordingly. On the other hand, when I take ...
4
votes
1answer
249 views

when timing a command execution time with sudo, `time` should be before `sudo` or after `sudo`?

when timing a command execution time with sudo, time should be before sudo or after sudo? time sudo command or sudo time command which one is correct? the output seems very different to me ...
4
votes
2answers
650 views

Memory usage command with syntax similar to the time command

What command shows the memory usage of a program, i am looking for a command that is simple to use and has similar syntax to the time command. I am trying to find the memory usage of a md5 hashing ...
4
votes
4answers
826 views

How to prevent atd from running past jobs?

The at daemon is a great tool! However, if a job is scheduled for 8:00 am and the machine is off at that time, at will run the job whenever the machine is booted. What I would like to do is stop it ...
4
votes
1answer
413 views

Renaming files from bash in linux

There is a bunch of files of the following format hh-mm-ss.png where hh, mm, ss are hour, minute and second. How can I rename all these files in the directory in a sequential way from 1.png til n.png ...
4
votes
1answer
168 views

When was file created [duplicate]

How can i see when a file was created. I have looked at man page ls -lc is for last modification of file status ls -lu for access time ls -l not exactly indicated which time, last changed? I ...
4
votes
1answer
224 views

Execution time and resources after processes that has been running for so long

This might be a basic question, but I am getting hard time finding an answer to it. I am using RHEL6. After running any process that takes significant cpu time, I get a line that tells (I guess) the ...
4
votes
3answers
3k views

Time synchronization in XFCE 4.8

Apparently there is no gui in XFCE (as there was in gnome) to synchronize time with NTP (if there is one, please let me know the name of the application). So, how can I synch with the time servers? ...
4
votes
1answer
1k views

bash terminal [\t] (time) is not same timezone as 'date'

In my .bashrc file I configured how I would like my prompt to be displayed. My .bashrc is sourced in .bash_profile. The command in the .bashrc file is: PS1='[\t] \u@\h is $PWD :: ' I switched the ...
4
votes
1answer
51 views

bash's builtin time accepts %E - what's going on?

The bash man page lists three and only three format codes recognized by the shell's builtin version of time: %R for the real time, %U for the time spent in userspace, and %S for time spent in system ...
4
votes
2answers
253 views

How to control the time that users spend on

I need a solution that allows me to control the time that each user spend on the computer, excluding idle time (some kind of parental control). I've tried timekpr, but it doesn't work on Ubuntu 13.10. ...