Quote:
Originally Posted by
wereyou
Thanks, HPAVC
This is what I have. Your command works but I just want to read the Lates/current file so I put *0209_TWSMERGE.log which works but I will probably have to change it again tomorrow?
I might be way to sleepy to understand the problem, i assume you have a directory full of log files and every so often a new one is made.
"ls -ctr PATTERN" should list the contents
-t sort by modification time
-r reverse order while sorting
-c just one column
so if the files where
mon.txt
thu.txt
tues.txt
wed.txt
ls -ctr *.txt would list them
mon.txt
tues.txt
wed.txt
thu.txt
the tail -1 just lists the last file (the newly modifed one)
so "cat `ls -ctr *.txt | tail -1`" gives cat the newest modified file.
if the issue is that you want some sexy 'look busy' dedicated window that always has the tail -f LATESTFILE going. yeah some sort of loop would be needed or a sexy tail. I dont know the tail command you have but ...
#
# this will try and get a PID from something and when that PID dies it will
# 'untail', then re-tail
#
while true; do
PID=`cat /var/run/TWSMERGINGTHING.pid`
tail --pid=$PID --follow `ls -ctr *_TWSMERGE.log | tail -1`
sleep 5
done
#
# this will keep tailing until the file goes sour (100 attempts looking
# at it with the no changes) and then it will get a new one
#
while true; do
tail --max-unchanged-stats=100 --follow `ls -ctr *_TWSMERGE.log | tail -1`
sleep 5
done
if you have a 'runfor' like command then obviously you could do that for "runfor 3600 tail ..." and it would run it for an hour and then retail every hour.
now for sleep