Please help me in finding a solution for tailing multiple log files and writing all of them into one common file.
I have 4 log files with same name in 4 different folders.
Whenever I post a Request - any one of these 4 log files gets updated with some log detail in the below format :
Logging can happen in any of the above 4 logfile.log instances each time a request is sent to the Server.
I check if logging happens or not by tailing all the above 4 instances in 4 different windows which is very ineffective.
I want to make this simple by writing some script that will look up if any of the log files get updated whenever a request is sent & then write that line into one common file.
one method can be to writer the script which look the modification time and if it is different from the last modified time then tail last four line of that log file into common log file.
Are you saying that your tail -f commands are ineffective? Is it that you actually need to put al of these into the background so that they are all running:-
Sorry, I meant to say that tailing all the 4 logs in 4 different windows is not an efective way to verify.
Yes I want to put them in Background and Only tail file.log
Is there a way I can write these tail cmds in one script & execute that script whenever I want
Sorry I am new to this & trying to learn
---------- Post updated at 11:31 AM ---------- Previous update was at 11:30 AM ----------
No I haven't. Could you please help me how to ?
---------- Post updated at 12:09 PM ---------- Previous update was at 11:31 AM ----------
for file in /Top/*/logfile.log
do
logfiles="$logfiles -f $file"
done
if [ ! -z "$logfiles" ] # Just in case none are found
then
tail $logfiles # Implicit -f already in the $logfiles variable
fi
If the file filename expansion becomes too long, you may hit problems and have to convert it a little.