| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-14-2010, 05:21 AM
|
#1
|
|
LQ Newbie
Registered: May 2005
Location: Orebro, Sweden
Distribution: Gentoo and Kubuntu
Posts: 5
Rep:
|
Get a list of most accessed, "hot", files
Hello!
I have used search and google but i can't see to find an answer to this (if it's here please link and spank me for search-failing
I admin a server that serves small (static) images as part of a bigger site. There is about 1 TB of images, but most of the are seldom accessed.
The problem: Large cheap disks are slow and i would like to move the most accessed images to something faster (be it a server with faster disk in better raid or a machine with ram-cache or SSD or whatev). But how do i find the "top accessed files in period X"?
Anyone have an idea? It's probably an obvious cat-grep-sed-mangle of something in /proc but i just can't solve it on my own...
Thank you in advance!
BTW: We run Debian stable...
|
|
|
|
05-14-2010, 06:53 AM
|
#2
|
|
Member
Registered: Apr 2010
Location: Mumbai
Distribution: RHEL, Debian, Fedora, Ubuntu
Posts: 39
Rep:
|
The simplest way I could think of is using the inbuilt find command and its options
The command goes something like this
find / -name *.jpg -atime 1
The above command displays all the files which have been accessed a day ago.
See man find for more exact reference.
Cheers!!!
|
|
|
|
05-14-2010, 07:03 AM
|
#3
|
|
Member
Registered: Apr 2010
Location: Mumbai
Distribution: RHEL, Debian, Fedora, Ubuntu
Posts: 39
Rep:
|
man find
Quote:
-atime n
File was last accessed n*24 hours ago. When find figures out
how many 24-hour periods ago the file was last accessed, any
fractional part is ignored, so to match -atime +1, a file has to
have been accessed at least two days ago.
|
Read more
and you will find more...
|
|
|
|
05-14-2010, 08:35 AM
|
#4
|
|
LQ Newbie
Registered: May 2005
Location: Orebro, Sweden
Distribution: Gentoo and Kubuntu
Posts: 5
Original Poster
Rep:
|
Quote:
Originally Posted by __raHulk
man find
Read more
and you will find more...
|
Thanks! Thats obvious, why didn't i think of that myself
Given a short value for atime i would get a list i myself could store and process (as in "this file was also returnd as a when you asked the last time"). That could be a working (although maybe not the most elegant) solution.
The other solution, i just realized, is... of course... turn on access-logging and parse through those files. Dunno where my head's at today.
I have gotten enough answers to solve my problem, thanks! If anyone has a cooler way to do it - plase share if you feel you have the time to do so...
|
|
|
|
04-03-2012, 04:40 PM
|
#5
|
|
LQ Newbie
Registered: Apr 2012
Posts: 1
Rep: 
|
filetop
#!/usr/bin/perl
use Cwd;
use File::Touch;
use File::Temp qw/tempfile/;
use Time::HiRes qw/sleep time alarm/;
use Term::ReadKey;
my ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();
if($hchar < 10) {print "please increase window size"; exit; }
my $mydir = getcwd;
my ($fh, $tmpfile) = tempfile(UNLINK => 1);
while(1)
{
my $starttime = time;
eval {
local $SIG{ALRM} = sub { die "alarm\n" };
alarm 0.4;
$query = `find -newermm $tmpfile 2>&1`; #change to mm for writes only
touch($tmpfile);
@files = split(/\n/,$query);
alarm 0;
};
system('clear');
foreach $file(@files) { $filecount{$file}++; }
@sorted = sort {$filecount{$b} <=> $filecount{$a}} (keys %filecount);
for ($x = 0;$x < $hchar-2; $x++) {print $filecount{$sorted[$x]}."\t".$sorted[$x]."\n";}
my $endtime = time;
my $length = ($endtime-$starttime);
if ($length > 0.3) {print "program not designed for large trees, please use smaller tree.\n"; exit;}
print "\n$length"."s\n"
}
|
|
|
|
04-03-2012, 05:49 PM
|
#6
|
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,220
|
Interesting first post.
How about inotify ?.
Edit: - didn't realise this was an old post. @jongab, resurrecting such old posts is generally frowned upon.
But welcome to LQ anyway ... 
Last edited by syg00; 04-03-2012 at 06:11 PM.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:44 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|