Sponsored Content
Full Discussion: Access time of a file
Top Forums UNIX for Dummies Questions & Answers Access time of a file Post 302232359 by jim mcnamara on Thursday 4th of September 2008 10:02:42 AM
Old 09-04-2008
From the POSIX standards:
Quote:
4.7 File Times Update
Each file has three distinct associated time values: st_atime, st_mtime, and st_ctime. The st_atime field is associated with the times that the file data is accessed; st_mtime is associated with the times that the file data is modified; and st_ctime is associated with the times that the file status is changed. These values are returned in the file characteristics structure, as described in <sys/stat.h>.
st_atime == atime
st_ctime == ctime
st_mtime == mtime

Plus if you search the forum for file time you will find a lot of good information.

Broli - the definitions of these have been fixed for years - different apps do not violate those definitions. Things that can change mtime are opening a file for write/append or a call to utime() (e.g., touch). chmod or chown changes ctime, and utime or opening a file for read changes the atime. These values are NOT part of the file, they are file metadata maintained by the filesystem, as accessed thru the kernel.

Last edited by jim mcnamara; 09-04-2008 at 11:08 AM..
 

9 More Discussions You Might Find Interesting

1. AIX

Semi-operators using Root access all the time ?

I am just curious about your opinion on something which I am against. I work at the client location. Our office is very small (4 employees + 1 teamlead where 1 employee per 12hrs shifts) and we are responsible to process the reception of external files into the client's database via some tools.... (3 Replies)
Discussion started by: Browser_ice
3 Replies

2. Programming

time access in C

I've a problem with time functions in C. I get current time and convert it to local time and gmt time. But their value seems to be same.I think I'm missing something.. #include <stdio.h> #include <memory.h> #include <time.h> int main() { time_t now_local, now_gmt; ... (2 Replies)
Discussion started by: xyzt
2 Replies

3. Shell Programming and Scripting

need the last access time for a .gz file

i have file named aaaa. The file aaaa was zipped on one particular time. Need to know the command to find out when the file "aaaa" was actually zipped. (1 Reply)
Discussion started by: expert
1 Replies

4. UNIX for Dummies Questions & Answers

File access time does not change on some files

Hey All, I want to get the access time of files in a directory. I used ls -lu on a directory and picked a file that had the access time of Mar 1 and used cat to get the contents of the file. Then I used the ls -lu again and the access time changed on that file. Perfect !! Now if I cat a... (10 Replies)
Discussion started by: vipulgupta0
10 Replies

5. UNIX for Advanced & Expert Users

How to get access time of a file upto the precision of seconds?

Hi , How can I get the last access time of a file upto the precesion of seconds in Unix. I cannot use stat as this is not supported. (10 Replies)
Discussion started by: kanus
10 Replies

6. Red Hat

File access time issue

Hi, I am facing a weird file access time issue on redHat5.x. I have a program which will scan the files in the NFS system and delete files which are older than 4 days, before deleting files program will print the access time of the file. Some of the files are getting deleted which are not older... (1 Reply)
Discussion started by: Satyak
1 Replies

7. Red Hat

Access time of files and directories

My query please: What I saw how access times of a file and directories work. 1) For a file the access time is the time when I 1st access it after last modification of the file, i.e., if the file is modified at 10 AM and then I access it at 11 AM. After than whenever I access without... (7 Replies)
Discussion started by: ravisingh
7 Replies

8. UNIX for Dummies Questions & Answers

Does 'grep' update a file's access date/time?

I've got a job that finds and removes trace files based upon an access time of more than seven days (I've also tried a modify date). find TABC* -atime +7 -exec rm + find TABC* -mtime +7 -exec rm + Whether I use -atime or -mtime, the process seems to work sporadically. Sometimes it removes... (6 Replies)
Discussion started by: Scottie1954
6 Replies

9. Programming

Memory and cache access time discrepancy

#include<stdio.h> #include<stdlib.h> #include<sys/time.h> #include<time.h> #include "rdtsc.h" #define SIZE 4*64*1024 int main() { unsigned long long a,b; int arr={0}; int i; register int r; a=rdtsc(); r=arr; b=rdtsc(); printf("1st element Access Cycles = %llu\n",b-a); (2 Replies)
Discussion started by: Vaibhavs1985
2 Replies
UTIME(P)						     POSIX Programmer's Manual							  UTIME(P)

NAME
utime - set file access and modification times SYNOPSIS
#include <utime.h> int utime(const char *path, const struct utimbuf *times); DESCRIPTION
The utime() function shall set the access and modification times of the file named by the path argument. If times is a null pointer, the access and modification times of the file shall be set to the current time. The effective user ID of the process shall match the owner of the file, or the process has write permission to the file or has appropriate privileges, to use utime() in this manner. If times is not a null pointer, times shall be interpreted as a pointer to a utimbuf structure and the access and modification times shall be set to the values contained in the designated structure. Only a process with the effective user ID equal to the user ID of the file or a process with appropriate privileges may use utime() this way. The utimbuf structure is defined in the <utime.h> header. The times in the structure utimbuf are measured in seconds since the Epoch. Upon successful completion, utime() shall mark the time of the last file status change, st_ctime, to be updated; see <sys/stat.h>. RETURN VALUE
Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned and errno shall be set to indicate the error, and the file times shall not be affected. ERRORS
The utime() function shall fail if: EACCES Search permission is denied by a component of the path prefix; or the times argument is a null pointer and the effective user ID of the process does not match the owner of the file, the process does not have write permission for the file, and the process does not have appropriate privileges. ELOOP A loop exists in symbolic links encountered during resolution of the path argument. ENAMETOOLONG The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. ENOENT A component of path does not name an existing file or path is an empty string. ENOTDIR A component of the path prefix is not a directory. EPERM The times argument is not a null pointer and the calling process' effective user ID does not match the owner of the file and the calling process does not have the appropriate privileges. EROFS The file system containing the file is read-only. The utime() function may fail if: ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument. ENAMETOOLONG As a result of encountering a symbolic link in resolution of the path argument, the length of the substituted pathname string exceeded {PATH_MAX}. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
None. RATIONALE
The actime structure member must be present so that an application may set it, even though an implementation may ignore it and not change the access time on the file. If an application intends to leave one of the times of a file unchanged while changing the other, it should use stat() to retrieve the file's st_atime and st_mtime parameters, set actime and modtime in the buffer, and change one of them before making the utime() call. FUTURE DIRECTIONS
None. SEE ALSO
The Base Definitions volume of IEEE Std 1003.1-2001, <sys/stat.h>, <utime.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 UTIME(P)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy