Technical Discussion
  >> Web Design / HTML / Web hosting Forum


Register (or login) on our website and you will not see this ad.


  Print Thread
Standard User mikejp
(member) Wed 20-Jul-16 16:35:15
Print Post

Last accessed date/time


[link to this post]
 
I have been told that servers do not store this flag on files. I want to 'audit' my sites and ensure that files stored are needed, so last accessed would be very useful. Does anyone have a trick to get this info without interminable trawling of raw access files?
Standard User panda
(committed) Wed 20-Jul-16 18:10:56
Print Post

Re: Last accessed date/time


[re: mikejp] [link to this post]
 
If the Filesystem supports, you could use a perl script to interrogate each file with stat()
http://perldoc.perl.org/functions/stat.html

On a Linux box I use:

Perl
1
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("/path/to/file");

atime (the variable $atime above) is the last access time in seconds since the epoch.

Perhaps use in a 'for' loop to test each file.

Eats shoots and leaves.
Standard User mikejp
(member) Wed 20-Jul-16 21:49:46
Print Post

Re: Last accessed date/time


[re: panda] [link to this post]
 
Many thanks, Panda - working on that.


Register (or login) on our website and you will not see this ad.

Standard User micksharpe
(legend) Wed 20-Jul-16 22:09:23
Print Post

Re: Last accessed date/time


[re: mikejp] [link to this post]
 
You need to check that the atime field is maintained by the mounted file system.
Updating the atime every time a file is read causes a lot of usually-unnecessary IO, slowing everything down. So, some Linux distributions now default to the noatime filesystem mount option, which basically kills atimes, or else relatime, which only updates atimes once a limit has passed (normally once per day) or if the file was actually modified since the previous read. You can find if these options are active by running the mount command.
  Print Thread

Jump to