|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Please help the newbie.
I am very new to UNIX, but just playing around with cygwin, I can see that it will work nicely for a project I'm working on. Starting from any given directory, I want my app to spider and collect every filename, size, full path, created date, modified date and last accessed date and save this data in a text file. Yes, this is a server snapshot app to see if changes are made to a production server or if a QA server matches a test server, etc...
I wrote this in VB and although it worked great, it is very slow and if there are more than 100,000 files (which there frequently is) the program will crash or hang. Can anyone get me started on how write a batch that I can kick off every night and it will do the process noted above and save it to any delimted type file? I think I can write the batch code if I knew what commands would do what I need here. Thank you, Joe |
|
#2
|
||||
|
||||
|
you can try
ls -l to get detailed views for each file in a directory. you can use ls -Rl to recurse through subdirectories and list in full detail. That won't give full paths though. You could try writing a script using ls -d though, which lists directories, and loop through each directory listed recursively. And then you can pipe it all into a file. eg command >> filename appends the output of `command` running into `filename`.
__________________
~James [Not currently seeking freelance work] Like philosophy or interested in spirituality? Philosophorum. Game Dev Experts Forums Foresight Linux - Because your desktop should be cool! Linux FAQ FedoraFAQ UbuntuGuide |
|
#3
|
|||
|
|||
|
dx6490dude - you can't quite get everything you need. Unix file systems by default do not keep a separate time for the creation time and the last modified time. There are three times that are associated with a Unix file or directory:
A "ls -l" will only give you, by default, the last modified time or mtime. It will not give you the last accessed time nor the time of the last status change. There are options to get those values when passed to "ls" but unfortunately you can't get all of them at the same time - you'd have to do multiple passes with "ls" to be able to get them all. To implement what you want your easiest (well, in my book) way to do this is to look at writing a small C program to recursively traverse a directory tree and call fstat() on every file you find. However, there are other designs that you might want to consider. The "find" command can show you files that have had any of the three times changed since a start that you specify. For example, you can run a command like: Code:
find . -type f -amin -10 to find files that have been accessed in the last 10 minutes. Replace -amin with -mmin to find ones that have been modified within the last 10 minutes. Since there are 1440 minutes in a day you could use this to find out both modified and/or accessed files within the last day. That won't tell you though if any files have changed size. If you are paranoid about security then a file that changed size but didn't have any of the three times changed is likely a bad thing. In that case you might have to "go native" and write a C program to find all of this information at once.
__________________
Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums. Last edited by stdunbar : December 28th, 2005 at 12:17 PM. Reason: Fixed typo |
|
#4
|
||||
|
||||
|
If you can use perl, you might as well write a quick perl script to do this job for you.
Seriously though, what you're saying about checking versions between production and test servers makes me think that you really need to investigate version control programs. There are free ones such as CVS and Subversion and commercial ones such as Perforce that do exactly what you want. Not only that, they allow you to push out the version of the files you want quickly and easily.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month Looking for a perl job with kick-*** programmers in a well-known NASDAQ listed tech company with branches in the US and Europe? We're hiring. PM me for details. Requirements |
|
#5
|
|||
|
|||
|
I wrote this in VB and although it worked great, it is very slow and if there are more than 100,000 files (which there frequently is) the program will crash or hang.
the 1. probl you have is... you let people crete xthousend files the 2. probl you have is... you let people crete xthousend files the 3. probl you have is... you let people crete xthousend files .... the N. probl you have is... you let people crete xthousend files ... ... at least, as sys admd, you should know what they are able to do. the second is |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Please help the newbie. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|