How do I get my script to monitor a new file using tail?
Hi,
I have a script which basically watches a log file for new lines using tail, then takes action based on what is logged. I wrote a script to do this for me and its working great, my only problem is that once per week, this log file is archived to another directory, and a new log is created. I need to monitor the NEW log file, but even though the old one is moved, my tail which is always running (tail -f | while) still seems to be looking at the OLD file. How can I get my script to work and start reading the NEW log file each week? The only way I can think of to do this is to have another script which runs every week that kills my script and re-starts it...
Here is the specific line in my script where it stops and sits forever when the log file is archived (ASAI.log) and a new one is created:
tail -n1 -f /home/dirTalk/current_dir/oamlog/ASAI.log | while read output_line
Here is the entire script:
Last edited by vgersh99; 06-04-2009 at 02:49 PM..
Reason: code tags, PLEASE!
Hi there,
I have a problem here that involves bash script since I was noob in that field. Recently, I have to monitor data involve in logs so I just run command tail -f for the monitoring. The logs was generate every hour so I need to quickly change my logs every time the new hour hits according... (2 Replies)
Hi
Im looking to create a Aix script to monitor a file for once it's been updated and then send an email. I dont have great scripting knowledge and have only come up with the following so far
while true
do
find /home/test/AMQ* -mmin 1 > /home/test/scripts/output/MQERRORS
exec... (2 Replies)
hi All,
how to find a pattern in the log file & display the above and below line
for example in the log file, i have many lines, whenever i search for "Category" it should display the above line with only few parameter like i want only the location name & department name
Thu Jul 02 11:05:23... (2 Replies)
Trying to use code that I found to send only new lines out of a log file by doing:
while :; do
temp=$(tail -1 logfile.out)
awk "/$last/{p=1}p" logfile.out #pipe this to log analyzer program
last="$temp"
sleep 10
done
Script works fine when logfile is basic text, but when it contains... (2 Replies)
Hi,
Have written a script to monitor linux non standard log file based on line numbers, so each check store $otalinenum ..
then in next check after 10 minutes it compre the current_total_line_num > last_total_line_num then it will parse the log file from last_total_line_num to... (0 Replies)
Title: Use “tail -f” to monitor and report, but the top line should be always fixed on the screen.
Hi, dear Unix experts,
I am trying to find a Unix command (or scripting) on how to continuously display a text file of its last several lines of contents. But during this displaying, I want some... (2 Replies)
Hi
I am looking for a help in designing a bash script on linux which can do below:-
1) Look in a specific directory for any new files
2) Mail the content of the new file
Appreciate any help
Regards
Neha (5 Replies)
Discussion started by: neha0785
5 Replies
8. Post Here to Contact Site Administrators and Moderators
Kindly advice with shell script to monitor open file in linux, if the open file count is greater then 5000 then send me an email..
command : lsof | wc -l (0 Replies)
Hello,
I would like to write script to tail a file for different environment
But the number of lines are keep changing
How can I write a script
For example:
env could : A, B or C
and log files could be a.log, b.log and c.log
with the number of lines can change
say sometimes it 100 last... (9 Replies)