LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-03-2014, 09:03 AM   #1
rahil khera
LQ Newbie
 
Registered: Sep 2009
Posts: 14

Rep: Reputation: 0
Number of times a particular file is accessed in the system since it was created


Does Linux stores the number of times a file is accessed from the time it was created? If yes, in which log file or data structure does it store and how to access it. I want to move least used files from one directory to another directory on the basis of count of access of files.

Last edited by rahil khera; 03-03-2014 at 09:25 AM.
 
Old 03-03-2014, 09:35 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
i think you would have to hack something up using the stat command and creating a daemon with a loop that will stat files in a directory and store the access times in a log (and sort from most to least):
Code:
[schneidz@hyper ~]$ stat wilna.txt 
  File: `wilna.txt'
  Size: 31        	Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 153090      Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/schneidz)   Gid: (  500/schneidz)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-02-24 09:05:58.358434999 -0500
Modify: 2013-01-10 14:32:31.177434974 -0500
Change: 2013-01-10 14:33:01.078648009 -0500
 Birth: -
 
1 members found this post helpful.
Old 03-03-2014, 09:48 AM   #3
rahil khera
LQ Newbie
 
Registered: Sep 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Sir, does Linux OS do it by itself. Like it is showing Last Access Time of the file. Similarly, does it stores number of times files has been accessed ..???

Last edited by rahil khera; 03-03-2014 at 09:49 AM.
 
Old 03-03-2014, 09:51 AM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
not that i know of... thats why i suggested my hack. maybe someone who is knowledgeable will come by and suggest a better alternative.
 
Old 03-03-2014, 09:53 AM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,834

Rep: Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358Reputation: 1358
Yeah. you'll want auditd for that.

http://security.blogoverflow.com/201...ion-to-auditd/
 
2 members found this post helpful.
Old 03-03-2014, 07:18 PM   #6
byau
Member
 
Registered: Sep 2009
Location: Los Angeles, CA
Posts: 32

Rep: Reputation: 5
I was going to say "dnotify" which I used years ago. Went to go find a tutorial on it and it is obsolete (showing my age am I?) - however its replacement inotify is really powerful.

Included in all recent kernels.

It will take some programming on your part but you can customize this thing to monitor specific files - powerful stuff, and not too complicated if you take time to read through the tutorials:

http://www.ibm.com/developerworks/li...buntu-inotify/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Core file created with wrong pid number acanady Linux - Server 1 11-30-2011 04:40 PM
Is there a way to see how many times a file has be accessed via the internet? jim.thornton Linux - Newbie 1 07-25-2011 04:47 PM
shell script :: how to print string that appeared maximum number of times in file ?? mayankmehta83 Linux - Newbie 3 12-07-2009 08:44 AM
file created/accessed dates plainkeyman Linux - General 4 10-27-2005 08:34 PM
recent attack via phpBB, log files deleted? accessed file system outside /home/ enzo250gto Linux - Security 8 12-17-2004 02:51 PM


All times are GMT -5. The time now is 11:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration