473,289 Members | 2,040 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

How To Do It Faster?!?

Hello Simo & NG,
Correct me if I'm wrong but since it _seems_ that the listing doesn't
need to be up-to-date each minute/hour as the users will be looking
primarily for old/unused files, why not have a daily cronjob on the
Unix server to produce an appropriate file list on e.g. the root
directory of your file server?
You are correct. I don't need this list to be updated every minute/hour.
$ find . -type f -printf "%T@ %u %s %p\n" > /yourserverroot/files.txt


That is a nice idea. I don't know very much about Unix, but I suppose that
on a ksh I can run this command (or a similar one) in order to obtain the
list I need. If anyone knows if that command will run also on a simple ksh,
could please confirm that?

Moreover, I could run this script in a while loop, like:

while 1:
do

if -e [/yourserverroot/filesbackup.txt];
then
find . -type f -printf "%T@ %u %s %p\n" > /yourserverroot/files.txt
copy /yourserverroot/files.txt /yourserverroot/filesbackup.txt
else
find . -type f -printf "%T@ %u %s %p\n" > /yourserverroot/filesbackup.txt
fi

done

or something similar (I don't have Unix at hand now, I can not test the
commands and, as I said, I don't know Unix very well...). In this way, I
always have the filesbackup.txt up-to-date, as a function of the "find"
speed on the server.
Then my GUI could scan the filesbackup.txt file and search for a particular
user information.

Thanks to all the NG for your suggestions!

Andrea.

Jul 18 '05 #1
1 1970
an***********@tin.it writes:
$ find . -type f -printf "%T@ %u %s %p\n" > /yourserverroot/files.txt That is a nice idea. I don't know very much about Unix, but I suppose that
on a ksh I can run this command (or a similar one) in order to obtain the
list I need. If anyone knows if that command will run also on a simple ksh,
could please confirm that?


That depends on the unix flavor you're using -- my example was for GNU
utilities which are heavily used on (probably all) Linux systems.
BSDs, Solaris and other unixen have slightly different 'find' syntax.
Use "man find" to find out more about how 'find' works on your system.

On all systems I know, it goes like:

find <directory> [-switches ...]

where the switches vary depending on the system. In my example, I used
-type f (f as in file) to only list files (otherwise 'find' will
include directories too in the output) and -printf to include desired
data -- in this case, owner, last modified time, size, path -- in the
output (otherwise 'find' will only print the path).

You should at least go through the -printf formatting codes to see
what information you're able to include in the output (=> man find).

I used %T@ to print the last modified time in Unix time because it's
as simple as it can be: an integer, counting the number of seconds
since Jan 1 1970. Python's "time" module groks Unix time just like
that.
Moreover, I could run this script in a while loop, like:
Except that, I'd imagine, constantly traversing the filesystem will
seriously degrade the performance of the file server. You want to run
your script periodically over a day, maybe at times when the server is
inactive. Or hourly between 8am-4pm and then once at night.

In Unix, there's a facility called cron to do just that, it runs
scripts and commands over and over again hourly, daily, weekly, or
just whenever you want it. Consult your unix flavor's manual or
newsgroup on that.
copy /yourserverroot/files.txt /yourserverroot/filesbackup.txt
always have the filesbackup.txt up-to-date, as a function of the "find"
speed on the server.


Yes, creating a temporary file is a good approach. I'd suggest moving
the new list over the old one (mv tmpfile filelist.txt) instead of
copying, since usually move is merely a rename operation on the
filesystem and doesn't involve actually copying of any data.
br,
S

--
fi****************@iki.fi-spam
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Armin Rigo | last post by:
Hi! This is a rant against the optimization trend of the Python interpreter. Sorting a list of 100000 integers in random order takes: * 0.75 seconds in Python 2.1 * 0.51 seconds in Python...
23
by: YinTat | last post by:
Hi, I learned C++ recently and I made a string class. A code example is this: class CString { public: inline CString(const char *rhs) { m_size = strlen(rhs);
98
by: jrefactors | last post by:
I heard people saying prefix increment is faster than postfix incerement, but I don't know what's the difference. They both are i = i+1. i++ ++i Please advise. thanks!!
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
1
by: James dean | last post by:
I done a test and i really do not know the reason why a jagged array who has the same number of elements as a multidimensional array is faster here is my test. I assign a value and do a small...
9
by: VenuGopal | last post by:
Hi, why n++ executes faster than n+1..... or does it realli execute faster? thanks Venugopal.B
11
by: ctman770 | last post by:
Hi Everyone, Is it faster to save the precise location of an html dom node into a variable in js, or to use getElementById everytime you need to access the node? I want to make my application...
12
by: karthikbalaguru | last post by:
Hi, How is 'Int' Faster than 'Char' ? I think , 'Char' is small and so it should be easily & efficiently . Can someone here provide some info regarding this. Thanks and Regards, Karthik...
23
by: Python Maniac | last post by:
I am new to Python however I would like some feedback from those who know more about Python than I do at this time. def scrambleLine(line): s = '' for c in line: s += chr(ord(c) | 0x80)...
41
by: c | last post by:
Hi every one, Me and my Cousin were talking about C and C#, I love C and he loves C#..and were talking C is ...blah blah...C# is Blah Blah ...etc and then we decided to write a program that...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.