The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
file permission/acl: 2 users with write access on 1 file... elzalem Security 0 08-28-2008 02:25 AM
Processing a log file based on date/time input and the date/time on the log file primp Shell Programming and Scripting 4 03-16-2008 08:23 AM
[C++] File I/O (Reading from a Random-Access File) VersEtreOuNe High Level Programming 0 02-12-2008 01:34 PM
HPUX list files with access time more than 5 min mvrk HP-UX 2 08-22-2005 07:01 AM
HOw I can Know who Access my file!! geoquest UNIX for Dummies Questions & Answers 3 06-19-2002 03:10 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-04-2008
Registered User
 

Join Date: May 2008
Posts: 68
Access time of a file

I thought that access time of a file is time when the file was run last time (or I read somewhere that it's time when system lookup the file -> but I'm not sure when it really is)

How is it exactly?

Thank you for help!
Reply With Quote
Forum Sponsor
  #2  
Old 09-04-2008
Registered User
 

Join Date: Sep 2008
Location: Netherlands
Posts: 8
It's the time a process last accessed it to read/write contents.
Reply With Quote
  #3  
Old 09-04-2008
broli's Avatar
Registered User
 

Join Date: Dec 2007
Location: Argentina
Posts: 198
Quote:
Originally Posted by aluiken View Post
It's the time a process last accessed it to read/write contents.
i read somewhere the documentation for the c function stat, and describe what type of access changed the mod time.
im sure that tail (awk, head, and surely more) dont change it
Reply With Quote
  #4  
Old 09-04-2008
Registered User
 

Join Date: May 2008
Posts: 68
2Broli: Well and what is the access time for then? I mean if behaviour of programs is different..
Reply With Quote
  #5  
Old 09-04-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
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 07:08 AM.
Reply With Quote
  #6  
Old 09-04-2008
Registered User
 

Join Date: May 2008
Posts: 68
I made a simple script and copied the output:

Code:
file=example_1.sh;stat $file; cat $file >/dev/null; stat $file
Code:
  File: `example_1.sh'
  Size: 918             Blocks: 2          IO Block: 4096   regular file
Device: fh/15d  Inode: 2099578354  Links: 1
Access: (0744/-rwxr--r--)  Uid: (13654/vsetm7am)   Gid: (  200/ nofiles)
Access: 2008-09-02 21:47:11.000000000 +0200
Modify: 2008-09-02 21:47:11.000000000 +0200
Change: 2008-09-02 21:47:11.000000000 +0200
  File: `example_1.sh'
  Size: 918             Blocks: 2          IO Block: 4096   regular file
Device: fh/15d  Inode: 2099578354  Links: 1
Access: (0744/-rwxr--r--)  Uid: (13654/vsetm7am)   Gid: (  200/ nofiles)
Access: 2008-09-02 21:47:11.000000000 +0200
Modify: 2008-09-02 21:47:11.000000000 +0200
Change: 2008-09-02 21:47:11.000000000 +0200
How come that access time didn't change when data was accessed?
Reply With Quote
  #7  
Old 09-04-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Quote:
Originally Posted by MartyIX View Post
How come that access time didn't change when data was accessed?

We would need to know the OS and how the file system was mounted. As one example: Sun's mount_ufs man page documents the noatime option:
Quote:
By default, the file system is mounted with normal access time (atime recording. If noatime is specified, the file system will ignore access time updates on files, except when they coincide with updates to the ctime or mtime. See stat(2). This option reduces disk activity on file systems where access times are unimportant (for example, a Usenet news spool). noatime turns off access time recording regardless of dfratime or nodfratime. The POSIX standard requires that access times be marked on files. -noatime ignores them unless the file is also modified.
Another example: the source files might be on cd-rom.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0