Ctime: Difference between revisions

From Hackepedia
Jump to navigationJump to search
Frankk (talk | contribs)
No edit summary
m Minor editing and additions.
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Time of last change of the [[inode]].  This time is taken from the [[inode]] itself.
Time of last change of the [[inode]] (e.g. permissions, ownership, etc).  This time is taken from the [[inode]] itself.  The ctime does '''not''' indicate the "creation time" of the file.  Under some circumstances--specifically if the permissions and ownership in unchanged since the file was created--it may have the same value as the "creation time," but this is conincidence, and should not be relied upon.


  $ stat -s [[variables|$file_or_diskname]] | tr ' ' '\n' | grep ctime
  $ stat -s [[variables|$file]] | tr ' ' '\n' | grep ctime
  st_ctime=1130490970
  st_ctime=1130490970
  $ date -r 1130490970
  $ date -r 1130490970
  Fri Oct 28 11:16:10 CEST 2005
  Fri Oct 28 11:16:10 CEST 2005
  $ ls -lcT disk
  $ ls -lcT $file
  -rw-r--r--  1 root  wheel  33554432 Oct 28 11:16:10 2005 disk
  -rw-r--r--  1 root  wheel  33554432 Oct 28 11:16:10 2005 file


Usually when the [[mtime]] gets updated the [[ctime]] will be updated as well for example when the file size changes this has to be reflected in the [[inode]].
Usually when the [[mtime]] of a file is updated, the [[ctime]] will be updated as well.  For example, when the size of a file is changed, this must be reflected in the metadata stored in the [[inode]]; thus, the ctime is updated appropriately.


The ctime is also a good place to check for new files written or updated in your system in the last few days (2 in this example)
Using the ctime value is also a good way to check for new files written or updated in your system in the last few days (2 in this example)


  $ find . -ctime -2 -print | wc -l
  $ find /path -ctime -2 -print | wc -l
       38
       38

Latest revision as of 11:23, 27 January 2006

Time of last change of the inode (e.g. permissions, ownership, etc). This time is taken from the inode itself. The ctime does not indicate the "creation time" of the file. Under some circumstances--specifically if the permissions and ownership in unchanged since the file was created--it may have the same value as the "creation time," but this is conincidence, and should not be relied upon.

$ stat -s $file | tr ' ' '\n' | grep ctime
st_ctime=1130490970
$ date -r 1130490970
Fri Oct 28 11:16:10 CEST 2005
$ ls -lcT $file
-rw-r--r--  1 root  wheel  33554432 Oct 28 11:16:10 2005 file

Usually when the mtime of a file is updated, the ctime will be updated as well. For example, when the size of a file is changed, this must be reflected in the metadata stored in the inode; thus, the ctime is updated appropriately.

Using the ctime value is also a good way to check for new files written or updated in your system in the last few days (2 in this example)

$ find /path -ctime -2 -print | wc -l
     38