Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I assume you mean you are reading the output from a ksh file, not reading the ksh prog file.
Where does the 2 mins thing come from?
Does the ksh prog produce a new file every 2 mins?
Does it output for 2 mins then overwrite the same file?
In either case, synchronisation is key to avoid losing data.
This link is PERL code and i am not familiar with PERL coding. I have never used PERL and also File tail wouldn't this get the end of the file. my file as soon as new message arrives it overwrite the previous message so i am not sure if this will do what i want.
I can't use cron scheduler and this why I am not sure how i could solve this issue.
The ksh file produces new message every couple seconds and each new message overwrites the previous message.
my file as soon as new message arrives it overwrite the previous message
Taking this to mean what it says, you are saying that the output_file (using that term loosely) only ever actually contains one msg (the latest), which is overwritten by the next/new msg approx(!) every 1 or 2 secs.
in that case, I don't get the 2 mins thing at all. You've got to grab each msg immediately or you will lose it...
So, you do need to use something like that Perl module or eg
tail -f output_file | your post-processing prog
In fact, you could use the first example on that Perl page pretty much as is.
Going back to bash soln, maybe instead of having the ksh file write to the ever-changing file, just pipe the output directly thus
ksh_prog | post-process_prog
# or output to log and pipe to prog
ksh_prog | tee ksh.log | post_process_prog
Thank you all for replying, but I think I havenít explained myself.
I have .ksh file which contains XML messages.
What I need is to parse and capture this XML messages then store the output in log file.
The two minutes thing is something I came up with as the log file could be a large file if I get each message output to it. But if I collect the messages for 2 minutes then I will be able to get summary output as this example: