Sponsored Content
Full Discussion: Help on scripting using tail
Top Forums Shell Programming and Scripting Help on scripting using tail Post 302073967 by ranj@chn on Friday 19th of May 2006 02:02:50 AM
Old 05-19-2006
Try like this!! Not sure if it is efficient.

while read -p err_line
do
echo $err_line | grep "pattern" && echo "mailx scripts goes here"
done


For the change of timestamp in the logfile, you could check for the time in this loop and exit it after 00:00 and then start the loop again. See if this works for you.
You can catch the pid of the background job and kill it before you reassign the logfile name,But make sure you have lot of error check into the script. I did it below like this.
while true #the main loop
do
tail -f $logfile |&
while read -p line
do
job_id=$! #get the background job process id

echo $line | grep "pattern" && echo "mailx scripts go here"

if [[ `date +%H` -lt 1 -a `date +%M` -gt 5 ]]; then #check for your time
break; #break out from loop
fi
done

kill $job_id #kill the id

sleep 5 # wait for sometime for the kill to complete its action.

logfile="$LOG/May_19.log" #reassign logfile
done

Last edited by ranj@chn; 05-19-2006 at 03:08 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Tail User

Ok i looked through quite a few posts but could not find what i was looking for so forgive me if this post can be found elese where... I would like to use a command like tail view what users are doing in the system i have quite a few dba's that come come to my office and do work on the system... (7 Replies)
Discussion started by: bbutler3295
7 Replies

2. Shell Programming and Scripting

How to terminate a tail -f

I am developing a script with a tail -f in it. My problem is how to terminate it and execute the next line. (4 Replies)
Discussion started by: DonVince
4 Replies

3. Shell Programming and Scripting

using tail -f

Working in HP-UX 10.20. I eventually want to write a bourne shell script to handle the following problem, but for now I am just toying with it at the command line. Here's what I am basically trying to do: tail -f log_X | grep n > log_Y I am doing a tail -f on log_X . Once it sees "n", I... (6 Replies)
Discussion started by: cdunavent
6 Replies

4. Shell Programming and Scripting

tail command..

I was wondering how can I do this I have file myfile.txt wc -l is: 5 000 000 I have to remove first 1 000 000 lines from header.. I tryed with tail -4000000 myfile.txt>newfile.txt but it does not work... any help?? (2 Replies)
Discussion started by: amon
2 Replies

5. Shell Programming and Scripting

Tail??

Hello all, I have search the forum and could not find an answer...Here is what I am trying to do. Every 15 minutes, a script send uptime output to a logfile (dailylog.log), that file contains lines like the one below: 11:21am up 44 days, 19:15, 1 user, load average: 0.00, 0.02, 0.03 ... (7 Replies)
Discussion started by: qfwfq
7 Replies

6. Shell Programming and Scripting

tail -f

I am trying to extract a particular line from a.log which keeps appending every sec and output that into a newfile b.log which should append itself with filtered data received from a.log I tried tail -f a.log |grep fail| tee -a b.log nothing in b.log tail -f a.log |grep fail >>b.log ... (4 Replies)
Discussion started by: wannalearn
4 Replies

7. Shell Programming and Scripting

tail -f monitoring

Is there any file on UNIX that changes periodically so that I could use tail -f command to watch changes? I was searching a long time and I didn't find nothing (I'm newbie to UNIX so it's not a surprise to me though) Thanks for help :) (6 Replies)
Discussion started by: MartyIX
6 Replies

8. Shell Programming and Scripting

tail out of memory

Hi, I am performing a tail command on EBCDIC coded files and am getting the following error message when I try to process very large files. tail: There is not enough memory available now. The file in question has more than 10 millions lines. I would like to ask for advice for... (4 Replies)
Discussion started by: Indalecio
4 Replies

9. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

10. Shell Programming and Scripting

Tail +

because the tail +2 on the first line gives me the file name pomga I do not want anything like what I miss tail +2 ejemplo.txt ouput ==> ejemplo.txt <== 1 2 3 4 5 6 7 8 9 10 (2 Replies)
Discussion started by: tricampeon81
2 Replies
MTAIL(1)							   User Commands							  MTAIL(1)

NAME
mtail - tail variant designed for web developers monitoring logfiles SYNOPSIS
mtail [options] <file>... DESCRIPTION
MonkeyTail allows a user to tail multiple files on both local and remote hosts and clearly marks inactivity by putting 5 newlines in the output whenever a pause in output over 3 seconds is detected. MonkeyTail is implemented a fairly simple wrapper script around standard tail, ssh, and sudo. OPTIONS
-q Quiet mode --quiet " " -n Output the last N lines of each file before tailing (defaults to 0) <file>... Files to tail. These can specified in the following ways: @<groupname> - expands the group (from .mtailrc) to a list of files to tail <filename> - tails a local file. +<filename> - attempts to sudo and tail a local file (will prompt for pwd if required). <remotehost>:<filename> - attempts to invoke tail via ssh on a remote host. +<remotehost>:<filename> - attempts to invoke sudo tail via ssh on a remote host (will prompt for pwd if required). SEE ALSO
mtailrc(5), tail(1) AUTHOR
Martyn Smith <martyn@dollyfish.net.nz> mtail May 2008 MTAIL(1)
All times are GMT -4. The time now is 01:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy