The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: read() without changing atime ?
Arcanus
Newbie
Rank: 1



UID 56
Digest Posts 0
Credits 0
Posts 16
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:11 AM  Profile | P.M. 
read() without changing atime ?



read() without changing atime ?



hey,

first of all i want to know how do i see the atime of a file ?? whats the command ??

i think ls -l shows the last modified time right ? because when i use cat to read a file, the timestamp shown by ls -l does not change.

its not ls -lu ! man ls did not help ! how do i see the last access time of a file in unix ???

now my next question is:

my c program reads a file using read(). but i do not want the last access time of the file to change. so, i am using utime() to update the atime and mtime of the file back to what it was before the read.

but the problem, the update will fail if the program does not have write permissions on the file. if the file is read only, the program will not be able to modify its attributes (am i right ?).


can you guys please help me out here

thanks,


Top
aznjason
Newbie
Rank: 1



UID 63
Digest Posts 0
Credits 0
Posts 45
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:12 AM  Profile | P.M. 
did you miss "some filesystems have a mount option to inhibit atime updates"? sometimes i wonder why i bother typing stuff in.  

well, for those who actually read what i write, solaris ufs filesystems such as exist on solaris 8, have such an option and it is mentioned on this page.
quote:
noatime

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).
Top
Anghus
Newbie
Rank: 1



UID 54
Digest Posts 0
Credits 0
Posts 38
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:12 AM  Profile | P.M. 
hey perderabo, i am not mounting anything.. i just created a file on my home directory.

(do u mean that my home directory was mounted with no atime updates ?? i never made use of any nfs mount command explicitly)

i examined the /etc/mnttab which contains the table of mounted file systems (mentioned in that link) if this table shows what optins were used to mount my home directory, then i did not see anything such as 'noatime' against my home dir as the mount point. (the options i saw were: nfs rw,intr)

i appreciate your reply perderabo.. i really dont know whats going on here..

thanks again
Top
bochgoch
Newbie
Rank: 1



UID 73
Digest Posts 0
Credits 0
Posts 56
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 15, 2007 08:12 AM  Profile | P.M. 
hmm..

thanks for your time perderabo, i will see what i can do.. try and contact the system admin..
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:31 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005251 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP