Solved

Linux access time efficiency question

Posted on 2013-01-05
8
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 78

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 78

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
 
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 78

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Samba Question 11 106
Linux mount of Windows Shared Now Fails 8 115
parallel rsync issues with Ubuntu 1 40
Can't connect to FTP 18 104
rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
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.…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

749 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