Some character adding up starting of log file?
The logrotate is setup in one of the RHEL Machine and I could see surprising character at the top of the log file as:
^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@ upto certain lines everytime. What could be the issue. |
Exactly which file is this junk appearing in?
|
Its a customized log location in a file with extension .log
Generally what could be possiblilty of being ^@ added at the line 1 If I do :2 in commandline of log file it works fine. |
Quote:
Also, maybe it isn't important, but this logfile, it is a log created by what application? Or is it a common/usual Linux system generated log? In other words, what process(s) are writing to the logfile? |
Code:
#!/bin/bash |
OK, so would it be fair to suppose that this problem has little or nothing to do with `logrotate`, but
is very likely to have something to do with that script: /tools/jboss/jboss4/jboss-as/bin/run.sh either directly, or indirectly via a problem or typo with one of those arguments provided to the script: -b testserver11.com -c testserver.com \ -Datg.dynamo.data-dir=/fixer/hjs/config/ATG-Data \ -Datg.dynamo.server.name=testserver.com If you have double-and-triple checked that all these command-line arguments are correct, I would be then looking at the above mentioned script itself. Is there code inside the `run.sh` script which would generate literally the junk you get in the log? If so, examine the conditions required to cause the junk to be outputted. Has this process ever worked correctly in the past? Without the crap in the logs? I.e. have you used this software before and it worked OK? If so, what's different this time? Sasha |
My logrotate file:
Code:
##################### Source log file ###################### |
My run.conf file:
Code:
Code:
#!/bin/sh |
Seems that run.sh is making the log file as binary.
The log created is a data file not normal log file. |
How to delete the first line of a file without creatign the temporary file?
I have a log file which generates the junk character at the first line. I want to write a script to remove it without disturbing the file or creating the temporary file(
I tried this : sed 1D test > tempfile. But I dont want to create a temp file as jboss might be using that file. Can it be done? |
How about using the in-place flag
Code:
sed -i 1D test |
Can I make it this way:
I need a script which will copy the log file(say A) in seperate new file(say B). Remove the first line from B and copy it back to A. Will it affect the log writing. anyone who can help me with this script. |
evo2,
Never used that command option -i. Will it not disturb the log writing. Are you sure? |
Quote:
Quote:
Evo2. |
A question: Can you not wait until the process has finished writing to the file?
Evo2. |
Hi,
About sed's -i option: Quote:
evo2 has a good point in post #6. Why can't you wait? |
If you write line by line to the file then just omit the first line which is given by the process write the remaining lines.
|
Now thats me really confused !!
Code:
A question: Can you not wait until the process has finished writing to the file? |
Hi,
At a certain point your program (the one that writes to the logfile) stops. Once that happens you can edit the logfile without having to worry about the program writing to it. |
At some point the process will stop or be killed: eg. when you shut down your machine, or when the logs are rotated.
Evo2. |
The Issue is I can't wait for that.
Let me elaborate. There is some junk character being added looks like ^@^@.......which fills up at first line only consuming more and more size..that makes upto 500-700MB size(surprisingly).So That makes my logs over loaded. Once i delete the first line then it freed 500-700 MB. Donno th reason why it does show. but All I temporarily need to delete the first line. So Cant wait.. Any Suggestion? |
Is there any method I can include the sed script at postrotate directive in logrotate.conf?
Anyone who can help me with what postrotate can do ? |
Hi,
To my knowledge there isn't a way to do this (lets hope I'm wrong about this, but I doubt it). I would suggest, if at all possible, to have a look at the program that generates the logfile and make sure (add some code) the first line (the one with 'junk') isn't put in the logfile but discarded. Hope this helps. PS: Maybe your idea about logrotate could work. I'm not too familiar with it so maybe others can assist with that. |
I tried addding this way:
Code:
#!/bin/bash |
I think the best thing to do here is work out why you are getting that first line of rubbish in the log file. What program is it?
Evo2. |
Hi,
Quote:
But..... Depending on the frequency of the logging it _might_ work. If nothing is logged while you run the above script it will work, if on the other hand the program does log one or more entries while you run the script, those entries will not show up in the log. Hope this helps. |
I have pasted run.sh above. Anyone who have hands on Jboss and could solve the issue.
|
1. Give me the output of file <log_filename>.
2. Who is writitng this log. (Any java code) ? This seems to me some kind of binary data been written in to your log file (A mix of ascii and binary I guess). The best way is to identify the Root cause. |
Code:
file testfile.log Code:
-rw-r--r-- 1 weadmin admingrp 3922 Mar 2 06:56 testfile.log |
@your_shadow03: This is a binary formatted file, _not_ a text file.
You still haven't mentioned what program creates/writes to this log file, but it is done in a binary format. |
My run.conf says:
Code:
JAVA_OPTS="-server -XX:PermSize=128m -XX:MaxPermSize=256m -XX:-PrintTenuringDistribution -XX:NewSize=256m -XX:MaxNewSize=384m -XX:+UseParallelGC -XX:SurvivorRatio=12 -Xmx1280m -Xms1280m -XX:ThreadStackSize=256 -XX:+DisableExplicitGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:ParallelGCThreads=2 -Xloggc:/project/gm.log -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true" |
Code:
JAVA_OPTS="-server -XX:PermSize=128m -XX:MaxPermSize=256m -XX:-PrintTenuringDistribution -XX:NewSize=256m -XX:MaxNewSize=384m -XX:+UseParallelGC -XX:SurvivorRatio=12 -Xmx1280m -Xms1280m -XX:ThreadStackSize=256 -XX:+DisableExplicitGC -verbose:gc -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:ParallelGCThreads=2 -Xloggc:/project/gm.log -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dsun.lang.ClassLoader.allowArraySyntax=true" Quote:
Secondly, I am still not sure how can you be so sure that these junk character will be there on the first line. For me these are gc logs and can be at any place. Do you find any exception just above or below these junk character in the log file? You can try invoking this java command on the command line to see what could be the probable exeception that is dumping these chars in the gc log file. |
Hi,
I'm not a java man, but doesn't this: -Xloggc:/project/gm.log mean you are logging the garbage collector? I do believe you need a special viewer to 'see' that data. A quick search comes up with GCView (freshmeat). Hope this helps. |
Can anyone confirm the same as I am not sure if that could be the reason.
What entry I should make to the file? |
your_shadow03,
I've yet again merged two of your threads on the same subject; you've been warned for double-/ multi-posts so many times it's not even funny. Next double post of yours I'll give you an out-time of a few weeks. Cheers, Tink |
Sorry Moderator,
The Two Thread are different but the result will the same. Thats what made me ask in different respect. Anyway, I am trying to get help from experts in two different ways. anyway, will take care for next time. |
Guys !!!
What my main aim is to remove this first line with junk character. I did attempted removing the line through script but couldnt make it happen. It does disturb the logs provisioning. But ASAP I copy it temporarily to a file , make changes and copy it back those characters again appear. Seems that something has to be done with run.sh (==<< Main culprit). |
Hi,
I've re-read most of the merged thread and see one thing that I cannot place: You (the OP) mention that the following line is in your run.conf file: CustomLog "| /usr/sbin/logrotate /mc.com/gm.log 60" common Should that be there? To my knowledge that entry isn't jboss specific (looks more like apache/tomcat). Hope this helps. |
I dont think it should affect the logs being provisioned as binary format.
|
Hi,
Have you actually tried to remove it. |
Well,, I am not in corporate VPN..
Will surely give it try and let you know the status. You can suggest me the other options too..if thats in your mind. I have put the same query to Jboss Community too. Lets see if it could be helpful. |
I tried it now..
It's not provisioning this time since that is only entry in run.conf. Removing it from the file will not provision the logs. |
Hi,
It is the only entry?? I doubt it. This was provided by you in post #8 as being the content of run.conf: Quote:
- Both entries seem to point to gm.log (the -Xloggc:/mc.com/gm.log in the JAVA_OPTS line). |
All times are GMT -5. The time now is 11:53 AM. |