LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Timestamp of Directory is Updated Whereas Files are Still Having Old Timestamps (https://www.linuxquestions.org/questions/linux-general-1/timestamp-of-directory-is-updated-whereas-files-are-still-having-old-timestamps-4175580155/)

devUnix 05-19-2016 03:01 AM

Timestamp of Directory is Updated Whereas Files are Still Having Old Timestamps
 
Hi,


This may sound a very easy question but I am wondering as to why the timestamp of the directory is updated / current whereas the files inside it have not been updated or no new file has been created therein:

Code:

[root@ms00443 bpbkar]# ls -ltr
total 14004
-rw-rw-rw-. 1 root root 895307 Apr 22 22:08 log.042216
....
-rw-rw-rw-. 1 root root 369390 May 18 21:44 log.051816


[root@ms00443 bpbkar]# cd ..
[root@ms00443 logs]# ls -ld bpbkar/
drwxrwxrwt. 2 root root 4096 May 19 00:00 bpbkar/
[root@ms00443 logs]# date
Thu May 19 07:31:28 GMT 2016


rtmistler 05-19-2016 07:12 AM

Maybe a file was deleted. Not sure if a directory gets it's timestamp updated when you access it. I think not actually. But clearly if you change the contents, it will change the directory timestamp. And one way to change contents is removal of a file. Therefore you would not see any file with the corresponding timestamp.

sundialsvcs 05-19-2016 08:20 AM

Also, not all filesystems actually update these timestamps. (In some cases, it's an option that you can configure.)

Although they are, in a sense, "convenient," the act of updating them means several additional round-trip disk-I/O operations, and they cause the physical areas on the disk which contain this information to be highly contended-for. The physical read/write head is forced to move-around much more than it otherwise could ... "and, for what?" Yeah, you might update something in it when you're having to read/write it for some other purpose, but otherwise it's just noise-traffic.

DavidMcCann 05-19-2016 12:10 PM

As rtmistler says, the ls command gives the time that the item listed was modified, so if it's a directory that could include deleting a file, moving one in, or moving one out — not just altering a file.

Access times are not given unless you ask with ls -lu but they are always recorded. You can use noatime and nodiratime as mount parameters in /etc/fstab to stop that, if you want to.


All times are GMT -5. The time now is 02:04 PM.