Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > What does the output of return os.lstat(logFile)[ST_CTIME] mean?

Reply
Thread Tools

What does the output of return os.lstat(logFile)[ST_CTIME] mean?

 
 
alberttresens
Guest
Posts: n/a
 
      07-26-2010

Hi,
I am trying to get the creation time of a file to be able to correlate it's
content timestamps with other log files.
In order to get the creation time of the file one a Linux machine i used:

return os.lstat(logFile)[ST_CTIME]

That returns to me something like: 1279620166

I would like to know the meaning of this number.
Is it in seconds since the epoch?
Or is some other respresentation?

Thanks,
Albert
--
View this message in context: http://old.nabble.com/What-does-the-...p29268605.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-26-2010
On Mon, 26 Jul 2010 09:54:23 -0700, alberttresens wrote:

> Hi,
> I am trying to get the creation time of a file to be able to correlate
> it's content timestamps with other log files. In order to get the
> creation time of the file one a Linux machine i used:


You're out of luck. Neither Unix nor Linux store the creation time of
files, at least not on any file system I know of. It stores three
timestamps: mtime, ctime, and atime.

atime is the simple one -- it is "access time", or when the file was last
read.

mtime is "modification time" -- it is when the file *contents* were last
changed.

But ctime is NOT creation time, as many people imagine. It is "change
time", and it changes whenever EITHER the file contents are changed, OR
when the file metadata (permissions, owner, name, etc.) change.

So any time mtime changes, so does ctime. But not visa versa.


> return os.lstat(logFile)[ST_CTIME]
>
> That returns to me something like: 1279620166
>
> I would like to know the meaning of this number. Is it in seconds since
> the epoch?


Yes.




--
Steven
 
Reply With Quote
 
 
 
 
alberttresens
Guest
Posts: n/a
 
      07-26-2010

Hi, thanks for the reply.

But what i am more concerned about, as I am trying to correlate logs, is
what is the timestamp:
1279620166 mean?
Is it seconds since the epoch or the ISO time in seconds?

Any idea?

Thanks a lot!!


Steven D'Aprano-7 wrote:
>
> On Mon, 26 Jul 2010 09:54:23 -0700, alberttresens wrote:
>
>> Hi,
>> I am trying to get the creation time of a file to be able to correlate
>> it's content timestamps with other log files. In order to get the
>> creation time of the file one a Linux machine i used:

>
> You're out of luck. Neither Unix nor Linux store the creation time of
> files, at least not on any file system I know of. It stores three
> timestamps: mtime, ctime, and atime.
>
> atime is the simple one -- it is "access time", or when the file was last
> read.
>
> mtime is "modification time" -- it is when the file *contents* were last
> changed.
>
> But ctime is NOT creation time, as many people imagine. It is "change
> time", and it changes whenever EITHER the file contents are changed, OR
> when the file metadata (permissions, owner, name, etc.) change.
>
> So any time mtime changes, so does ctime. But not visa versa.
>
>
>> return os.lstat(logFile)[ST_CTIME]
>>
>> That returns to me something like: 1279620166
>>
>> I would like to know the meaning of this number. Is it in seconds since
>> the epoch?

>
> Yes.
>
>
>
>
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


--
View this message in context: http://old.nabble.com/What-does-the-...p29268871.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
Thomas Jollans
Guest
Posts: n/a
 
      07-26-2010
On 07/26/2010 07:24 PM, alberttresens wrote:
>
> Hi, thanks for the reply.


Alas, you didn't actually read it:

>
> But what i am more concerned about, as I am trying to correlate logs, is
> what is the timestamp:
> 1279620166 mean?
> Is it seconds since the epoch or the ISO time in seconds?
>
> Any idea?
>
> Thanks a lot!!
>


[...]

>>> I would like to know the meaning of this number. Is it in seconds since
>>> the epoch?

>>
>> Yes.


You quoted the answer to your question in the same e-mail. fascinating.

A little side note:

>> atime is the simple one -- it is "access time", or when the file was
>> last read.


You should never rely on this, though: some file systems don't store
this (I think) and many users/sysadmins actually disable this
(mount -o noatime) for performance reasons. (Also, on an SSD, I imagine
enabling atime, and with it many, many additional writes, could
noticeably detriment disk lifetime)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
what does "execfile" mean within profiler output and why does it not have a attached line number Rahul Python 4 04-07-2009 03:19 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
difference between return &*i and return i; Ganesh Gella C++ 4 11-12-2004 04:28 PM
How do I return a return-code from main? wl Java 2 03-05-2004 05:15 PM
Return a return value from Perl to Javascript PvdK Perl 0 07-24-2003 09:20 AM



Advertisments