1

When I ls a file the last modified date shows as Nov 29 11:13, am but stat shows the file changed at Dec 3rd, why is the date different on ls and stat output.

-rw-rr 1 iadm sys     266240 Nov 29 11:13 log_backup_1_0_26337600_26341632.1417281197106
-rw-rr 1  iadm sys    1585152 Nov 29 11:13 log_backup_0_0_0_0.1417281197131


stat log_backup_0_0_0_0.1417281197131
  File: `log_backup_0_0_0_0.1417281197131'
  Size: 1585152         Blocks: 3096       IO Block: 32768  regular file
Device: 22h/34d Inode: 17232       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1002/  iadm)   Gid: (   79/  sys)
Access: 2014-11-29 11:13:17.000000000 -0600
Modify: 2014-11-29 11:13:17.000000000 -0600
**Change: 2014-12-03 09:56:57.618281823 -0600**
 Birth: -


stat log_backup_1_0_26337600_26341632.1417281197106
  File: `log_backup_1_0_26337600_26341632.1417281197106'
  Size: 266240          Blocks: 520        IO Block: 32768  regular file
Device: 22h/34d Inode: 17231       Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1002/  iadm)   Gid: (   79/  sys)
Access: 2014-11-29 11:13:17.000000000 -0600
Modify: 2014-11-29 11:13:17.000000000 -0600
**Change: 2014-12-03 09:56:57.606281658 -0600**
 Birth: -
Braiam
  • 35,991
Jonu
  • 11
  • 1
  • 2

1 Answers1

0

ls -l shows only the time of last modification of the content of the file, and stat additionally gives you time of last change of the file in the file system structure (inode modification).

For example lets compare time stamp before and after a change of the file name:

$ touch abc.txt
$ stat abc.txt

(...)
Access: 2014-12-05 19:23:18.515079101 +0000
Modify: 2014-12-05 19:23:18.515079101 +0000
Change: 2014-12-05 19:23:18.515079101 +0000

$ mv abc.def def.txt
$ stat def.txt

(...)
Access: 2014-12-05 19:23:18.515079101 +0000
Modify: 2014-12-05 19:23:18.515079101 +0000
Change: 2014-12-05 19:24:45.306744159 +0000

Notice the same "Modify" time, but time of last "Change" has changed.

If you want to see "Change" time with ls use -lc option, from man ls:

-c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime, newest first

So:

$ ls -l def.txt
-rw-r--r-- 1 jimmij jimmij 0 Dec  5 19:23 def.txt
$ ls -lc def.txt
-rw-r--r-- 1 jimmij jimmij 0 Dec  5 19:24 def.txt
jimmij
  • 47,140