Timestamp of Directory is Updated Whereas Files are Still Having Old Timestamps
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.