Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does a UNIX directory change its timestamp

I used "touch" on a file, updating the file's timestamp but the parent directory's timestamp did not change. However, (as expected) when I created a new file within the parent directory, the directory's timestamp did change.

What criteria do UNIX-like operating systems (specifically AIX) use to determine when to update the timestamp of a directory?

like image 963
Scrubbie Avatar asked Aug 10 '10 17:08

Scrubbie


People also ask

Does mv command change timestamp?

mv will always update the timestamp on the directory it moves files/directories from and the directory into which it moves files/directories. (Basically, it modifies these directories, so of course it updates their modify timestamp, so long as the filesystem in question has modify timestamps.

What is modification time in Unix?

The modified time is when a file last had its contents modified. And the change time is when a file last had its metadata changed (such as file permissions or the name of the file).


1 Answers

The timestamp is updated when the data that represents the directory changes. A change in a subdirectory of directory D does not change anything in the representation of D because D only points to the subdirectory, not to what's inside it. On the other hand, creating a file in D changes the block of data on disk that represents D.

like image 114
Pascal Cuoq Avatar answered Oct 18 '22 10:10

Pascal Cuoq