Questions tagged [timestamps]

timestamp is used for questions that are about data specifying seconds since the epoch (19700101T00:00:00) or possible some other standard, and also for (date) and time information in filenames.

UNIX timestamps are often based on the count of seconds since the beginning of the day Jan 1st, 1970 (UTC).

Timestamps are used to distinguish otherwise identically named items, as well as a tag events (e.g. in log files) so they are not just sequentially ordered but can be related to real-time events.

As part of file names, timestamps are often used as the system provided timestamps (available via stat) can change if files are later updated.

559 questions
358
votes
11 answers

Prepending a timestamp to each line of output from a command

I wish to prepend a timestamp to each line of output from a command. For example: foo bar baz would become [2011-12-13 12:20:38] foo [2011-12-13 12:21:32] bar [2011-12-13 12:22:20] baz ...where the time being prefixed is the time at which the line…
anon
268
votes
3 answers

Get file created/creation time?

Possible Duplicate: How do I do a ls and then sort the results by date created? Is there a command in Linux which displays when the file was created ? I see that ls -l gives the last modified time, but can I get the created time/date?
linuxAddict
220
votes
4 answers

Delete files older than X days +

I have found the command to delete files older than 5 days in a folder find /path/to/files* -mtime +5 -exec rm {} \; But how do I also do this for subdirectories in that folder?
Teddy77
  • 2,883
  • 7
  • 23
  • 34
187
votes
7 answers

How do I do a ls and then sort the results by date created?

In what order are the dated ordered by? Certainly not alphanumeric order. ls -lt sorts by modification time. But I need creation time.
InquilineKea
  • 6,152
  • 12
  • 43
  • 42
175
votes
1 answer

What is the difference between modify and change in stat command context?

The stat command's manual page says: %x Time of last access %y Time of last modification %z Time of last change I cannot understand the difference between modify and change. I understand the words are synonyms (English is not…
Andrew-Dufresne
  • 5,663
  • 7
  • 25
  • 19
167
votes
7 answers

Why does find -mtime +1 only return files older than 2 days?

I'm struggling to wrap my mind around why the find interprets file modification times the way it does. Specifically, I don't understand why the -mtime +1 doesn't show files less than 48 hours old. As an example test I created three test files with…
Mike B
  • 8,769
  • 24
  • 70
  • 96
130
votes
8 answers

How can get the creation date of a file?

I want to find out the creation date of a particular file on a Linux system. Not the modification date or access date, the creation date. I have tried with ls -ltrh and stat filename but neither gives me what I need. What else can I do to get this…
Özzesh
  • 3,549
  • 8
  • 23
  • 25
84
votes
15 answers

What are the legitimate uses of the `touch` command?

What's the point of the touch command? I know I can create empty files with it, but so is also the case with echo -n. Otherwise, why would someone need to change the timestamps of a file? Unless to create the false impression about the age of a…
Quora Feans
  • 3,806
  • 7
  • 29
  • 46
51
votes
7 answers

How can I do a "copy if changed" operation?

I would like to copy a set of files from directory A to directory B, with the caveat that if a file in directory A is identical to a file in directory B, that file should not be copied (and thus its modification time should not be updated). Is…
Brooks Moses
  • 615
  • 1
  • 5
  • 7
49
votes
6 answers

How to list files that were changed in a certain range of time?

How can I list recursively all files that were changed between 22.12.2011 and 24.12.2011?
clamp
  • 1,633
  • 6
  • 19
  • 31
45
votes
5 answers

How to get milliseconds since Unix epoch?

I want to do a bash script that measures the launch time of a browser for that I am using an html which gets the time-stamp on-load in milliseconds using JavaScript. In the shell script just before i call the browser I get the time-stamp with: date…
Eduard Florinescu
  • 11,153
  • 18
  • 57
  • 67
45
votes
4 answers

Changing the timestamp of a symlink

I know how to change the timestamp of a regular file: touch -t 201301291810 myfile.txt I was not able to do the same with a symlink. Is it possible? Distro: RHEL 5.8
amphibient
  • 12,222
  • 18
  • 62
  • 87
45
votes
5 answers

Why does "ls -all" show time for some files but only year for others?

If you issue the ls -all command some files are displayed with the timestamp containing the year without the time and others with the timestamp containing the time but not the year. Why does this happen? Is the timestamp representative of the time…
Jonathan Kittell
  • 732
  • 1
  • 9
  • 18
41
votes
4 answers

What file systems on Linux store the creation time?

Are there any (good known, reliable) file systems on Linux that store the creation time of files and directories in the i-node table? If there are, is the "changed" time replaced by the creation time of an i-node in a stat call?
franziskus
  • 875
  • 2
  • 7
  • 9
40
votes
2 answers

Why does Unix store timestamps in a signed integer?

Why is a signed integer used to represent timestamps? There is a clearly defined start at 1970 that's represented as 0, so why would we need numbers before that? Are negative timestamps used anywhere?
Bakudan
  • 525
  • 1
  • 4
  • 8
1
2 3
37 38