I am looking for a list of actions that can performed that will result in a directories modification time being updated. Off the top of my head:
- Create a new file in the directory
- Delete a file in the directory
What am I missing?
I am looking for a list of actions that can performed that will result in a directories modification time being updated. Off the top of my head:
What am I missing?
In Linux (in most Unices, in fact), directories are like files containing simple tables that look like:
So, these "files" (directories) are changed when you make changes to this table. It changes when you add or remove entries from that table (like you noted), but that applies to directories too, not only files. You can't change the inode of an existing entry, but you can change the name that links to that inode (rename a file). So:
These are the operations that changes the modification time of a directory.
At a macro level, there is one interesting observation.
When you use certain tools that tend to make a temporary file in the local directory (instead of /tmp), and these files are usually hidden (starting with a
.
), without any apparent change in the directory, you find its modification time changed.One such case is when you open a file in
vi
that makes a temporary (.filename.swp) file and then exit the file w/o making any changes. The swap file was created and deleted, modification time of the directory was also changed.Nothing wrong with this, but helps to know what happened. And, if you are bothered with that, there is a way to stop it too.
You can 'touch' the directory to update the date/time of it as well, without changing contents.