need help ksh scripting for log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help ksh scripting for log file
# 1  
Old 02-08-2008
need help ksh scripting for log file

I have log files that contain data generated every 5 minutes.

I want to extract data from the log files to another log file

In each 5 minute series

<log4j:event logger="VistaMonitor" timestamp="1200688175425" time="Fri Jan 18 15:29:35 EST 2008"

Generated twice (I only to get the date once)

Further in the log file I need to extract from this line:

JMS: IntegrationFrameworkJMSServer.InboundQueue: 1,1,13479,13514,1,81700

I need the third value '13479' and last value '81700'

The script I was successful in putting together a script to tail the data but I want to extract the data one line per 5 min period
from a complete file.

Any suggestions would be helpful

Current Script:

#!/bin/ksh

MONITORLOG="/opt/bea/weblogic81/config/WebCTDomain/logs/webct_monitor.log"
LOG="/export/home/oracle/lmbct.log"

#DATE=`date +%m/%d/%Y-%H:%M`

WAIT=`grep " JMS: IntegrationFrameworkJMSServer.InboundQueue: " ${MONITORLOG} |t
ail -1 |cut -d',' -f 6`

DATE=`date +%m/%d/%Y-%H:%M`
HOSTNAME=`hostname`


echo "${DATE},${HOSTNAME},${WAIT}" >> ${LOG}
# 2  
Old 02-08-2008
You can try to use a loop with the sleep command with a delay of 5 minutes:

Code:
#!/bin/ksh

MONITORLOG="/opt/bea/weblogic81/config/WebCTDomain/logs/webct_monitor.log"
LOG="/export/home/oracle/lmbct.log"
HOSTNAME=`hostname`

while :
do
  WAIT=`grep " JMS: IntegrationFrameworkJMSServer.InboundQueue: " ${MONITORLOG} |tail -1 |cut -d',' -f 6`
  DATE=`date +%m/%d/%Y-%H:%M`
  echo "${DATE},${HOSTNAME},${WAIT}" >> ${LOG}
  sleep 18000
done


Regards
# 3  
Old 02-10-2008
Further Clarification on my needed script.

Thanks for the quick reply. Yes, your script works great on the active log and my script above seems to capture the values every 5 minutes using crontab.

However, I have these huge monitor logs that have be rolled over and have not been captured by my new script. So, I have a 5 Gb log file filled with thousand
of logs generated every 5 minutes. I need to purge this file, take out the date from the log4j properties either from the real date or timestamp. This row:

<log4j:event logger="VistaMonitor" timestamp="1200688175425" time="Fri Jan 18 15:29:35 EST 2008"

then about 50 rows followng this date I need two values out of this line:

JMS: IntegrationFrameworkJMSServer.InboundQueue: 1,1,7405,10136,1,28506


I can't seem to capture the date: Jan 18 15:29 or the timestamp 1200688175425 and translate it. Then I can get one value - say 7405 but not both -

7405,28506

So, I have a huge log file and I need the following:

1/18/2008 15:29,7405,28506

and to have it print out all the dates and data for the whole file to a separate log file. Is it possible?
Thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh scripting SSH to Compare File Sizes

Hello, I currently have very little experience with Shell scripting and trying to create a script for the purpose of collecting the size of a couple sizes on 4 different Hosts. The Idea is to collected the information from the files in which the script is kicked off on, store the values into... (17 Replies)
Discussion started by: Abstract3000
17 Replies

2. Shell Programming and Scripting

Ksh: How to write the log file simultaneously when .sql file executes by UNIX process

Hello Team- we would like to implement an approach which has to write the log file simultaneously when .sql file is executing by Unix process. At present,it is writing the log file once the process is completed. I've tested the current process with the below approaches and none of them... (1 Reply)
Discussion started by: Hima_B
1 Replies

3. Shell Programming and Scripting

ksh : need to get the 4 th line above and 2 nd below the matched pattern in the log file

I have a log file as given below 012/01/21 10:29:02 (111111) Processing Job '23_369468343464564' 2012/01/21 10:29:02 (111111) Making Job '23_369468343464564.0'... 2012/01/21 10:29:04 (111111) Jobnumber '23_369468343464564' was successful 2012/01/21 10:29:04 ... (12 Replies)
Discussion started by: rpm120
12 Replies

4. Shell Programming and Scripting

ksh shell scripting to copy a file

Hi. I am a new Unix admin and I've been tasked to write a ksh script that copies my .profile into my /home directory on all servers. I'm new to this and having a difficult time scripting it. Any ideas? (6 Replies)
Discussion started by: david_tech
6 Replies

5. Shell Programming and Scripting

Create Log File in ksh itself

Hi, I want to create a log file for a running ksh , and the log file absolute path I want to give in ksh itself. To elaborate this - Say I have a ksh - timer.ksh and I want to create a log timer_log.log when I run, to trace this. I am aware of the fact that this can be done using redirection... (4 Replies)
Discussion started by: vinay4889
4 Replies

6. Shell Programming and Scripting

How to add trailer record at the end of the flat file in the unix ksh shell scripting?

Hi, How to add trailer record at the end of the flat file in the unix ksh shell scripting can you please let me know the procedure Regards Srikanth (3 Replies)
Discussion started by: srikanth_sagi
3 Replies

7. Shell Programming and Scripting

Read from Log file in Ksh

I have a log file like.. IMPORT from /dataserver/ftp/bits/mdr/mdr_data_discon.dat OF DEL ..... Number of rows read = 1376 Number of rows skipped = 0 Number of rows inserted = 1374 Number of rows updated = 0 Number of rows rejected = 2 Number of rows... (4 Replies)
Discussion started by: ramse8pc
4 Replies

8. Shell Programming and Scripting

How to create file in ksh scripting with permission(rw-rw-rw)

Hi, Please provide your inputs.. Thanks in Advance, Mansa (1 Reply)
Discussion started by: mansa
1 Replies

9. Shell Programming and Scripting

file handling with ksh scripting

how can i write content of a variable to a file? how can i read standard output into a variable? (1 Reply)
Discussion started by: gfhgfnhhn
1 Replies

10. Shell Programming and Scripting

Posting to a log file in KSH

Hello, I am writing this script in ksh (consisting of various functions such as -> read_file, write_file, pront_output and initialise) which basically process input files based on the parameters it contains. My task now is to write any error conditions trapped by any of the function above to... (2 Replies)
Discussion started by: sidamin810
2 Replies
Login or Register to Ask a Question