Continious tailing of a log files, changing inodes
I have to write a script that will copy the output from a system log file, and place it into an area of the file system that is accessable via a webreport.
The easiset way is just to tail the output file and send it elsewhere, ie:-
tail ServerEngine.log > /opt/sw/reports/servereport.txt
However, the engine producing the log will zip up the original file and create a new one with the same name. The running tail process won't pick up the new file as it has a different inode.
I'm thinking the best way to approach this would be to find the inode based on the filename (ServerEngine.log) and start a process that tails that, sending the output to serverreport.txt
The script will monitor the inode number associated with ServerEngine.log in a loop, and when it notices a change, kill the original tail process and start a new one.
Can anyone think of a better way to do this ?
|