Solved

Linux access time efficiency question

Posted on 2013-01-05
8
214 Views
Last Modified: 2013-01-21
This is not a "how to", I just want to understand something.

As we know Linux is a very efficient system. However this concept of access time has me a little confused.

For example, if I did a find through the whole OS would it update the access time on every file? It just seems that would be incredibly inefficient with umteen file system writes to update a time stored on the hard disk for every file found.

If not does it get updated with an "fopen" statement or something else.

In other words, can someone tell me exactly what constitutes the access time getting updated?

Thanks... just furthering my in depth knowledge of Linux.
0
Comment
Question by:RegProctor
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 9

Assisted Solution

by:gt2847c
gt2847c earned 167 total points
ID: 38747929
Access time is file opened for reading
Modified time is changes to file content

So unless the kernel executes the system call open(), the access time won't change.  Find is reading directory entries, and not opening the file (unless you are using the -exec function/option to perform something like grep on the current file)
0
 
LVL 76

Expert Comment

by:arnold
ID: 38747991
if you see a data file such as binary file where you do not want access time updated since it has no value, you can mount the partition with the noatime option.
The noatime option is usually used on partitions where binary database files are stored.
0
 
LVL 11

Assisted Solution

by:un1x86
un1x86 earned 333 total points
ID: 38748084
Hi

Checkout the answer I have written here
http://www.experts-exchange.com/OS/Unix/Q_27821074.html

For example, if I did a find through the whole OS would it update the access time on every file? It just seems that would be incredibly inefficient with umteen file system writes to update a time stored on the hard disk for every file found.

Open in new window


The access times of the files will not change as they will not be read. But the access time of the folder where the file is in will change. See this example

Create a file and get stat information
root@solidamber-kernel-x64:~# touch /tmp/file

root@solidamber-kernel-x64:~# stat /tmp/file
  File: `/tmp/file'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: fe01h/65025d	Inode: 1010095     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-06 07:29:33.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100

root@solidamber-kernel-x64:~# stat /tmp
  File: `/tmp'
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: fe01h/65025d	Inode: 1085281     Links: 11
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-05 21:31:40.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100

Open in new window


Seach for the created file and read information

root@solidamber-kernel-x64:~# find /tmp -name file
/tmp/file

root@solidamber-kernel-x64:~# stat /tmp/file
  File: `/tmp/file'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: fe01h/65025d	Inode: 1010095     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-06 07:29:33.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100

root@solidamber-kernel-x64:~# stat /tmp/
  File: `/tmp/'
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: fe01h/65025d	Inode: 1085281     Links: 11
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-01-06 07:29:49.000000000 +0100
Modify: 2013-01-06 07:29:33.000000000 +0100
Change: 2013-01-06 07:29:33.000000000 +0100 

Open in new window


As you can see. Only the access time of the folder has changed.
0
 
LVL 76

Expert Comment

by:arnold
ID: 38748500
Access time is updated on every access to a resource.
This is the question the asker has is whether the update to the access time is an efficient use of resources even though the two times updates are the same in most systems. There is the create date that is set when the resource is created, access time that is updated on every access and the last is the modify date which is updated when data is written into the resources.

To access a file in any directory, the directory must be accessed.

The reason access time updates are useful is this information is needed if you need to decide whether a set of files in a share can be archived because they are not being used.  Without this data point, your data repository can not be trimmed without going to each person collecting information on which files each accesses and then archive any file that is not included in the collected information.
0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 11

Accepted Solution

by:
un1x86 earned 333 total points
ID: 38748799
Arnold. The question was IF the access time of each found file would be updated if you do a find through the whole filesystem. The answer is NO. Find does not fopen all files that it is searching. The only access times that are updated, are the ones of the folders.

As long as you do not have any fopen syscalls it will not change your access time. Otherwise it will.
0
 
LVL 76

Expert Comment

by:arnold
ID: 38749118
misinterpreted the question.
0
 
LVL 1

Author Comment

by:RegProctor
ID: 38800783
I want to thank everyone. There is a lot of good information here.
0
 
LVL 1

Author Closing Comment

by:RegProctor
ID: 38800799
Terrific, thanks guys.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now