Computing.Net > Forums > Unix > how to list a directory in realtime

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to list a directory in realtime

Reply to Message Icon

Name: jabalio
Date: September 25, 2008 at 11:47:21 Pacific
OS: RH Linux
CPU/Ram: Linux workstation
Comment:

Hi folks,
Does anybody know how to list a directory in real time. (sort of what tail -f would do for a file), I need to be able to constantly poll a directory every 100miliseconds or so to see if a new file appears. if it does i need to exec certain function on them , For simplicity here, you can just assume i want to rename a file if it is created in a directory - in realtime. The dir needs to be polled for any new file created every 100ms. until stopped manually by hitting cntrl-C or similar.

Any advice will be very appreictaed



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: September 25, 2008 at 13:36:33 Pacific
Reply:

I'd have to think about it, but you could set up a while loop that sends ls -1t output to a file, execute another ls -l1 and compare that with the previous loop. If they are different then execute your function.

I think that getting 100ms granularity is going to be tough using Linux scripting tools.


0

Response Number 2
Name: wollie
Date: September 29, 2008 at 07:07:49 Pacific
Reply:

watch ls -al /directory

cheers

Wollie


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: how to list a directory in realtime

How to write a korn shell script www.computing.net/answers/unix/how-to-write-a-korn-shell-script/3643.html

how to replace a file in a .zip fil www.computing.net/answers/unix/how-to-replace-a-file-in-a-zip-fil/7497.html

how to replace a line in a file www.computing.net/answers/unix/how-to-replace-a-line-in-a-file/7214.html