How to tail log in one script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to tail log in one script?
# 1  
Old 02-26-2010
How to tail log in one script?

I have three prodcution box

Prod1
Prod2
Prod3

I want to write a script which tail the log for each production box
and put it into some file which I have want to tail

For example

Prod1
-----
Code:
TIMER IXN=MEMPUT, USR=GGu1, elapsed = 0.176 seconds.
11:41:44 [175] AUDIT MEMPUT: member IC:5151093501, being processed.
11:41:44 [178] TIMER IXN=MEMGET, USR=GGu1, elapsed = 0.282 seconds.
11:41:44 [178] TIMER MPI_InvokeCallback: IXN=MEMGET, USR=GGu1, CBTYPE=2, elapsed=0.009 seconds.
11:41:44 [178] TIMER MPI_InvokeCallback: IXN=MEMPUT, USR=GGu1, CBTYPE=1, elapsed=0.298 seconds.
11:41:44 [173] TIMER IXN=MEMGET, USR=GGu1, elapsed = 0.291 seconds.
11:41:44 [173] TIMER MPI_InvokeCallback: IXN=MEMGET, USR=GGu1, CBTYPE=2, elapsed=0.010 seconds.
11:41:44 [178] AUDIT MEMPUT: member IC:3514156955, being processed.
11:41:44 [173] TIMER MPI_InvokeCallback: IXN=MEMPUT, USR=GGu1, CBTYPE=1, elapsed=0.309 seconds.
11:41:44 [173] AUDIT MEMPUT: member IC:4615098331, being processed.
11:41:44 [150] AUDIT MEMPUT: member IC:556706375

Prod2
---
Code:
TIMER IXN=MEMPUT, USR=GGu1, elapsed = 0.176 seconds.
11:41:44 [175] AUDIT MEMPUT: member IC:5151093501, being processed.
11:41:44 [178] TIMER IXN=MEMGET, USR=GGu1, elapsed = 0.282 seconds.
11:41:44 [178] TIMER MPI_InvokeCallback: IXN=MEMGET, USR=GGu1, CBTYPE=2, elapsed=0.009 seconds.
11:41:44 [178] TIMER MPI_InvokeCallback: IXN=MEMPUT, USR=GGu1, CBTYPE=1, elapsed=0.298 seconds.
11:41:44 [173] TIMER IXN=MEMGET, USR=GGu1, elapsed = 0.291 seconds.
11:41:44 [173] TIMER MPI_InvokeCallback: IXN=MEMGET, USR=GGu1, CBTYPE=2, elapsed=0.010 seconds.
11:41:44 [178] AUDIT MEMPUT: member IC:3514156955, being processed.
11:41:44 [173] TIMER MPI_InvokeCallback: IXN=MEMPUT, USR=GGu1, CBTYPE=1, elapsed=0.309 seconds.
11:41:44 [173] AUDIT MEMPUT: member IC:4615098331, being processed.
11:41:44 [150] AUDIT MEMPUT: member IC:556706375

Prod3
----
Code:
TIMER IXN=MEMPUT, USR=GGu1, elapsed = 0.176 seconds.
11:41:44 [175] AUDIT MEMPUT: member IC:5151093501, being processed.
11:41:44 [178] TIMER IXN=MEMGET, USR=GGu1, elapsed = 0.282 seconds.
11:41:44 [178] TIMER MPI_InvokeCallback: IXN=MEMGET, USR=GGu1, CBTYPE=2, elapsed=0.009 seconds.
11:41:44 [178] TIMER MPI_InvokeCallback: IXN=MEMPUT, USR=GGu1, CBTYPE=1, elapsed=0.298 seconds.
11:41:44 [173] TIMER IXN=MEMGET, USR=GGu1, elapsed = 0.291 seconds.
11:41:44 [173] TIMER MPI_InvokeCallback: IXN=MEMGET, USR=GGu1, CBTYPE=2, elapsed=0.010 seconds.
11:41:44 [178] AUDIT MEMPUT: member IC:3514156955, being processed.
11:41:44 [173] TIMER MPI_InvokeCallback: IXN=MEMPUT, USR=GGu1, CBTYPE=1, elapsed=0.309 seconds.
11:41:44 [173] AUDIT MEMPUT: member IC:4615098331, being processed.
11:41:44 [150] AUDIT MEMPUT: member IC:556706375

I using tail -100 which is not correct as i want to capture logs by tail -f

Code:
#!/bin/ksh
BOX_LOGDIR="prod_01 prod_02 prod_03"
LOGDIR=/usr/local/cdi/data/prod_02/hub_instance/wag_prod85b/log
while true
do
for DIR in ${BOX_LOGDIR}
do
  FILE=$DIR
  export FILE1=`ls -t /usr/local/cdi/data/${DIR}/hub_instance/wag_prod85b/log/mpinet_wag_prod85b*.mlg | head -1`
  #export FILE1=`ls -t /home/csd/hxd/Harish/${DIR}/mpinet_wag_prod85b*.mlg | head -1`
   echo >>$LOGDIR/multi_engine.log 
   echo $FILE >>$LOGDIR/multi_engine.log
  tail -100 $FILE1 >>$LOGDIR/multi_engine.log
  echo >>$LOGDIR/multi_engine.log
done
sleep 10
done



---------- Post updated 02-26-10 at 12:12 PM ---------- Previous update was 02-25-10 at 01:46 PM ----------

Please reply if anybody know the solution of my problem.

Last edited by mr_harish80; 02-25-2010 at 02:15 PM..
# 2  
Old 02-26-2010
If these logs are syslog controlled, you can send them to a central machine for processing.
# 3  
Old 02-26-2010
This is not a syslog .
My motive is to tail the logs from three production server in one file
without logging individually into each production server.
# 4  
Old 02-26-2010
Please post the command(s) you use to see each individual log.
Btw. Blending the logs from three servers is unlikely to be sensible or practical.
Do you have a particular reason like monitoring each log for particular error messages?
# 5  
Old 02-28-2010
yes sometimes the my server and database intraction is very slow and this cause my production server to hang by some reason.
so ussally I have to login to different prodcution server and check the log detail.
I have wrote a code for this also which only give 100 lines of the logs at one time.

The scripts that in I have wrote is

#!/bin/ksh
BOX_LOGDIR="prod_01 prod_02 prod_03"
LOGDIR=/usr/local/cdi/data/prod_02/hub_instance/wag_prod85b/log
while true
do
for DIR in ${BOX_LOGDIR}
do
FILE=$DIR
export FILE1=`ls -t /usr/local/cdi/data/${DIR}/hub_instance/wag_prod85b/log/mpinet_wag_prod85b*.mlg | head -1`
#export FILE1=`ls -t /home/csd/hxd/Harish/${DIR}/mpinet_wag_prod85b*.mlg | head -1`
echo >>$LOGDIR/multi_engine.log
echo $FILE >>$LOGDIR/multi_engine.log
tail -100 $FILE1 >>$LOGDIR/multi_engine.log
echo >>$LOGDIR/multi_engine.log
done
sleep 10
done

In this case I have used -> tail -100 $FILE1 >>$LOGDIR/multi_engine.log

From this script I only tail -100 lines of log file from different server to multi_engine.log file I want to use tail -f in the script.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Alternative to tail -n -0 -F for monitoring live log file

Hello, I have been working on script which need to generate an alert based upon live logs. If string is found then an alert mail must triggered. tail -n -0 -F works fine to redirect the each latest line from live logs file to grep a pattern for matching but it seems to be not working on... (7 Replies)
Discussion started by: ketanraut
7 Replies

2. Shell Programming and Scripting

How to tail -f logfile. if log file is generate every 1 HR.?

Hello, How to tail -f logfile. if log file is gennerate every 1 HR. I want it works automatically all the time. never changes it by manual. Thank ls -trl CybertonTransaction.* -rw-r--r-- 1 autobot robot 617071 Jul 9 00:02 CybertonTransaction.20130709-00.log -rw-r--r-- 1 autobot ... (12 Replies)
Discussion started by: ooilinlove
12 Replies

3. Solaris

How to tail an installation log?

Hi Guys, when installing an application, I believe there is a log file which is create to log the progress of the installation. What I will like to know is, how do you tail the start log file to see the installation as it is progressing. I will really appreciate your help. Thanks (1 Reply)
Discussion started by: cjashu
1 Replies

4. Shell Programming and Scripting

tail and log rotation

Need some suggestion with an old problem form a thread here: https://www.unix.com/shell-programming-scripting/153204-multiple-not-statement-awk.html Since my log is large, I did get help to make a line that splits the log into two partstail -f syslog | awk '!/snmpd|ntpd|reject/{print | "tee... (1 Reply)
Discussion started by: Jotne
1 Replies

5. Shell Programming and Scripting

tail log on remote iPad

I have a jailbroken ipad acting as a window sign. It is running an app I wrote that plays a video over and over. Sometimes it stops working, so I set up a log to the device that I can read. I would like to get an alert when the log shows that the player has stopped working. I have openSSH set... (1 Reply)
Discussion started by: nextyoyoma
1 Replies

6. 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

7. Shell Programming and Scripting

how to run tail -f for 3 log files from a script

hi i need to run from a bash script tail -f /var/log/access_log >> access1 tail -f /var/log/prod/prod1 >> access1 tail -f /var/log/prod/prod2 >> access1 this script purpose is to start at server boot time and should always run. what is the best way to put it on a script Thanks Dan (1 Reply)
Discussion started by: dan12341234
1 Replies

8. Shell Programming and Scripting

how to tail a log file..

Hi All.. I have a log file in which all the backup information is stored. Now i have written a script which get the last line in the backup log file.. ssh -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" However i would like to tail the line last... (4 Replies)
Discussion started by: suri.tyson
4 Replies

9. Shell Programming and Scripting

Bash tail monitor log file

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)
Discussion started by: kriezo
2 Replies

10. Shell Programming and Scripting

tail -f a log file redirected into a new window?

Is this possible? I am attempting to display a new xterm window and tail -f the log file within that new window. I am currently working on a solaris 8 machine if that has any different meaning than the other platforms. As you can see, I am a newbie to this forum and to UNIX. Any help would be... (2 Replies)
Discussion started by: douknownam
2 Replies
Login or Register to Ask a Question