Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

monitor latestfile with timestamp 2

Status
Not open for further replies.

vuakhobo

Technical User
Apr 22, 2004
41
US
Current time: 11:11
is there a way to monitor file that come after 11:11?
I used ls -lart|tail -1 .it only show the latest file
 
man touch
man find

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
ls -t|wc -l # maybe = 20 files in directory

new files are created....

ls -t|wc -l could now have 23 files

ls -t |head -3

will list 3 latest files

 
cd /path/to/dir
touch now$$ # create a reference file
sleep 300 # wait for files to arrive
find . -newer now$$ -exec whatever_cmd {} \;

You can include other find search criteria e.g. a name pattern. Or in a loop, touch the ref file at every end of the iteration (before going to sleep).

cd /path/to/dir
process_all_files (find . -exec...)
touch now$$
sleep 300
while true
do
process files (find . -newer now$$ -exec...)
touch now$$
sleep 300
done

If you want this script to be restartable, perhaps you need a fixed ref-file name instead of "now$$", which would change on every invocation of the script (PID changes).

You take it from here.


HTH,

p5wizard
 
Thank you feheke,PHV,p5wizard and marrow very much for quick respond.. I appreciate your help alot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top