Difference between revisions of "Ctime"

From Hackepedia
Jump to navigationJump to search
m (Minor editing and additions.)
 
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]] | tr ' ' '\n' | grep ctime
 
  $ stat -s [[variables|$file]] | tr ' ' '\n' | grep ctime
Line 8: Line 8:
 
  -rw-r--r--  1 root  wheel  33554432 Oct 28 11:16:10 2005 file
 
  -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 12: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