- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Time stamps on directories/subdirectories and ...
Operating System - HP-UX
1754278
Members
2891
Online
108813
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2011 11:23 AM
тАО01-15-2011 11:23 AM
Hi All,
I had seen some situation where time stamp on directory/sub-directories was older but files it contains has newer ?
How does time stamp work in HP-UX or other Unix ?
Thanks,
Manoj
I had seen some situation where time stamp on directory/sub-directories was older but files it contains has newer ?
How does time stamp work in HP-UX or other Unix ?
Thanks,
Manoj
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2011 01:03 PM
тАО01-15-2011 01:03 PM
Solution
In a "standard" Unix system, each file and directory typically has three timestamps:
- mtime = time of last file modification. This is the timestamp you normally see in the "ls -l" listing, although you can see the other timestamps if you add the appropriate options to the ls command.
- ctime = time of last change of the inode metadata (= ownership, permissions, which disk blocks are allocated to this file, the count of hard links to a file, etc.)
- atime = time of last data access
The atime is usually the least useful of these three timestamps. If the filesystem is mounted with the "noatime" mount option, the atimes are not tracked, which reduces the number of disk writes required.
Someone may misguidedly talk about "creation time": this is a persistent misunderstanding. Please don't spread it.
Although *some* Unix filesystems may have one, it's not a standard Unix timestamp and HP-UX filesystems don't record creation times.
The name of the file is *not* part of the inode metadata: it's part of the directory the file is located in. This may be surprising, but it's related to the Unix feature of hard links.
In a Unix filesystem, a single file can effectively be present in multiple directories simultaneously, if multiple directories have a hard link to the inode of the file. A normal file with just one hard link is just a special case of that. The unique identifier of a file is *not* its name, but its inode number.
In Unix, directories are fundamentally just special files that map filenames to inode numbers. When you understand this, the behavior of the timestamps will start to make sense to you.
When you write to an existing file, you change the data within the file, and the block allocation information in the inode metadata, so both mtime and ctime will change. No changes are made to the directory, so the timestamps of the directory won't change.
When you create a new file, a new filename->inode mapping is added to a directory; so the directory's mtime and ctime are changed.
When you rename a file within a particular directory, you modify the directory, so the mtime and ctime of the directory are changed. The rename operation within a single filesystem is done by creating a new hard link using the new name, and deleting the old link, so the file's link count gets updated to 2 and then back to 1, and so the file's ctime gets updated too.
When you delete a file, you effectively remove its hard link from the directory it's in. This is a directory modification, so the directory's mtime and ctime are changed.
The link count in the file's inode is decremented by one; if *and only if* the link count reaches 0, all its hard links are gone, the file can be deleted and the disk blocks assigned to the file can be added to the list of free blocks. But if some process is currently accessing the file (has the file opened), this part of the removal operation will be delayed until the process closes the file.
MK
- mtime = time of last file modification. This is the timestamp you normally see in the "ls -l" listing, although you can see the other timestamps if you add the appropriate options to the ls command.
- ctime = time of last change of the inode metadata (= ownership, permissions, which disk blocks are allocated to this file, the count of hard links to a file, etc.)
- atime = time of last data access
The atime is usually the least useful of these three timestamps. If the filesystem is mounted with the "noatime" mount option, the atimes are not tracked, which reduces the number of disk writes required.
Someone may misguidedly talk about "creation time": this is a persistent misunderstanding. Please don't spread it.
Although *some* Unix filesystems may have one, it's not a standard Unix timestamp and HP-UX filesystems don't record creation times.
The name of the file is *not* part of the inode metadata: it's part of the directory the file is located in. This may be surprising, but it's related to the Unix feature of hard links.
In a Unix filesystem, a single file can effectively be present in multiple directories simultaneously, if multiple directories have a hard link to the inode of the file. A normal file with just one hard link is just a special case of that. The unique identifier of a file is *not* its name, but its inode number.
In Unix, directories are fundamentally just special files that map filenames to inode numbers. When you understand this, the behavior of the timestamps will start to make sense to you.
When you write to an existing file, you change the data within the file, and the block allocation information in the inode metadata, so both mtime and ctime will change. No changes are made to the directory, so the timestamps of the directory won't change.
When you create a new file, a new filename->inode mapping is added to a directory; so the directory's mtime and ctime are changed.
When you rename a file within a particular directory, you modify the directory, so the mtime and ctime of the directory are changed. The rename operation within a single filesystem is done by creating a new hard link using the new name, and deleting the old link, so the file's link count gets updated to 2 and then back to 1, and so the file's ctime gets updated too.
When you delete a file, you effectively remove its hard link from the directory it's in. This is a directory modification, so the directory's mtime and ctime are changed.
The link count in the file's inode is decremented by one; if *and only if* the link count reaches 0, all its hard links are gone, the file can be deleted and the disk blocks assigned to the file can be added to the list of free blocks. But if some process is currently accessing the file (has the file opened), this part of the removal operation will be delayed until the process closes the file.
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2011 10:38 PM
тАО01-15-2011 10:38 PM
Re: Time stamps on directories/subdirectories and files
Hi,
In addition to matti's eloquent explanation, i would also like to add that the find command can be used to search for files and directories with the atime, mtime and ctime options. However, you will see that the atime option is used when an administrator is trying to find or cleanup certain "large and old files". One more interesting point I would like to add is that doing a touch on an already created file just updates the timestamp.
Regards
Ismail Azad
In addition to matti's eloquent explanation, i would also like to add that the find command can be used to search for files and directories with the atime, mtime and ctime options. However, you will see that the atime option is used when an administrator is trying to find or cleanup certain "large and old files". One more interesting point I would like to add is that doing a touch on an already created file just updates the timestamp.
Regards
Ismail Azad
Read, read and read... Then read again until you read "between the lines".....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2011 08:22 AM
тАО01-16-2011 08:22 AM
Re: Time stamps on directories/subdirectories and files
Hi Manoj:
> I had seen some situation where time stamp on directory/sub-directories was older but files it contains has newer ?
That's not uncommon at all. The 'mtime' (modification timestamp) of a directory changes when files are added to it or removed from it. Changing a *file* within a directory will change the file's 'mtime' but not the directory's.
Regards!
...JRF...
> I had seen some situation where time stamp on directory/sub-directories was older but files it contains has newer ?
That's not uncommon at all. The 'mtime' (modification timestamp) of a directory changes when files are added to it or removed from it. Changing a *file* within a directory will change the file's 'mtime' but not the directory's.
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP