Dynamic time to append for every log info


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Dynamic time to append for every log info
# 1  
Old 07-10-2007
Dynamic time to append for every log info

Hi All,


What i am looking for:
i want to generate a dynamic system time for each and every data(line) which goes on generating data continously....

now i am using this script to append a time for dynamic data generation log file,

tail -f filename_error.log|awk -v var="$( date +%H":"%M":"%S" "%Y )" ' /parallel nursery GC/ || /GC/ { $0=$0 " " var } ; 1'
[INFO ][memory ] 7654.644: parallel nursery GC 1613483K->1441609K (2969600K), 58.004 ms 01:40:38 2007
[INFO ][memory ] 7672.245: parallel nursery GC 1636286K->1464021K (2969600K), 59.238 ms 01:40:38 2007
[INFO ][memory ] 7680.216: parallel nursery GC 1667206K->1494772K (2969600K), 58.330 ms 01:40:38 2007
[INFO ][memory ] 7691.249: parallel nursery GC 1691520K->1519101K (2969600K), 52.770 ms 01:40:38 2007
[INFO ][memory ] 7698.657: parallel nursery GC 1709864K->1537607K (2969600K), 52.452 ms 01:40:38 2007
[INFO ][memory ] 7705.461: parallel nursery GC 1760051K->1587293K (2969600K), 53.754 ms 01:40:38 2007
[INFO ][memory ] 7713.707:GC 1803076K->1630709K (2969600K), 52.372 ms 01:40:38 2007
[INFO ][memory ] 7705.461: parallel nursery GC 1760051K->1587293K (2969600K), 53.754 ms 01:40:38 2007



but i am looking for : a command that can generate the output as shown below .....

[INFO ][memory ] 7654.644: parallel nursery GC 1613483K->1441609K (2969600K), 58.004 ms 01:40:38 2007
[INFO ][memory ] 7672.245: parallel nursery GC 1636286K->1464021K (2969600K), 59.238 ms 01:40:45 2007
[INFO ][memory ] 7680.216: parallel nursery GC 1667206K->1494772K (2969600K), 58.330 ms 01:40:48 2007
[INFO ][memory ] 7691.249: parallel nursery GC 1691520K->1519101K (2969600K), 52.770 ms 01:40:52 2007
[INFO ][memory ] 7698.657: parallel nursery GC 1709864K->1537607K (2969600K), 52.452 ms 01:40:55 2007
[INFO ][memory ] 7705.461: parallel nursery GC 1760051K->1587293K (2969600K), 53.754 ms 01:40:59 2007
[INFO ][memory ] 7713.707:GC 1803076K->1630709K (2969600K), 52.372 ms 01:41:38 2007
[INFO ][memory ] 7705.461: parallel nursery GC 1760051K->1587293K (2969600K), 53.754 ms 01:41:42 2007



means the time should go on changing , i.e the output info as shown above should always append with a current system time ......

waiting for ur valuable suggestions.....eagerly

or



is there any another way to get the dynamic time generation to append for an dynamic data generation..................waiting for ur valuable suggestions........
# 2  
Old 07-10-2007
Try this:

Code:
tail -f filename_error.log | while read LINE
do
   D=`date +%H":"%M":"%S" "%Y`
   echo "$LINE" | awk -v var="$D" ' /parallel nursery GC/ || /GC/ { $0=$0 " " var } ; 1'
done


Bye Smilie
# 3  
Old 07-24-2007
Thanks Robotronic
its working fine and thanks a lot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on script to capture info on log file for a particular time frame

Hi I have a system running uname -a Linux cmovel-db01 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux I would like to capture the contents of /var/log/syslog from 11:00AM to 11:30AM and sent to this info via email. I was thinking in set a cron entry at that... (2 Replies)
Discussion started by: fretagi
2 Replies

2. Programming

Specifying dynamic library path to linker at compile time

I would like to compile a binary that doesnot depend on LD_LIBRARY_PATH as this binary will be setuid to owner and used by other users and since setuid doesnot support LD_LIBRARY_PATH making it independent of LD_LIBRARY_PATH would be great. But I am not able to specify the path of the shared... (1 Reply)
Discussion started by: waavman
1 Replies

3. Emergency UNIX and Linux Support

How to append date and time stamp before the two extensions?

hi, i have some file names. my file names are as follows: c_abc_new.txt.xls c_def.txt.xls i want to append date time stamp in the below manner. c_abc_new_YYYYMMDD_HH24MISS.txt.xls c_def_YYYYMMDD_HH24MISS.txt.xls check the two input file names, they differ in naming. the 1st file name... (9 Replies)
Discussion started by: Little
9 Replies

4. Shell Programming and Scripting

Create a file from ls -l command and append additional info to results

I need to be able to take the results from ls -l command and modify the output as follows: I will run ls -l *.mak My results will be aa.mak bb.mak cc.mak I then need to take those results and create a file that has the following info: dsjj/ubin/aa dsjj/ubin/bb dsjj/ubin/cc ... (3 Replies)
Discussion started by: jclanc8
3 Replies

5. Shell Programming and Scripting

append a filename with system date and time

Hi, There are similar kind of posts, but none seems like working for me. Please correct me if I'm wrong. I need append/rename file abc.txt with file processed date and time like abc_systemdatetimestamp.txt and move it to different folder. for example I have /source/data/abc.txt ... (1 Reply)
Discussion started by: amsn08
1 Replies

6. UNIX for Dummies Questions & Answers

How to append time to folder

Hi i just want to create a folder with current time. For example. foldername_09042010 How do i modify mkdir or write script to do this? (1 Reply)
Discussion started by: pinga123
1 Replies

7. Shell Programming and Scripting

Extract info from log file and compute using time date stamp

Looking for a shell script or a simple perl script . I am new to scripting and not very good at it . I have 2 directories . One of them holds a text file with list of files in it and the second one is a daily log which shows the file completion time. I need to co-relate both and make a report. ... (0 Replies)
Discussion started by: breez_drew
0 Replies

8. UNIX for Dummies Questions & Answers

Time difference between each line info....

Hi all, here is a problem, i am having a data in a file of this format, cat filename|grep -ivn edc|tr -s ' ' +|cut -d+ f1,12 1 01:18:38 2007 25 01:43:38 2007 48 01:58:45 2007 71 02:11:02 2007 102 02:19:51 2007 and so on ........ ....... . here... (4 Replies)
Discussion started by: gsp
4 Replies

9. UNIX for Advanced & Expert Users

Shell script to append a time for the existing error log file

Hi Guys, the requirement is like this, i am having a error log file in this format, 4594.493: parallel nursery GC 2594592K->2544691K (2969600K), 30.848 ms 4605.958: parallel nursery GC 2634887K->2584986K (2969600K), 38.900 ms 4619.079: parallel nursery GC 2822555K->2774812K... (12 Replies)
Discussion started by: gsprasanna
12 Replies

10. UNIX for Dummies Questions & Answers

Time service info

Where can i find info about the Time Service of UNIX ??? I need to "speak" with a machine which has UNIX os ( i know its IP address ) and to get from this machine its date or time. I work with Cygwin on my machine. any help will be welcomed .... (1 Reply)
Discussion started by: Inbal
1 Replies
Login or Register to Ask a Question