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. |
All times are GMT -5. The time now is 06:17 PM. |