Results 1 to 6 of 6
Hi
I am actually dealing with a large active log which is being filled in by our WEbsphere portal server.
When the log size gets to say 1GB we want ...
- 08-18-2008 #1Just Joined!
- Join Date
- Jun 2007
- Location
- UK
- Posts
- 14
alternate to cat > /dev/null
Hi
I am actually dealing with a large active log which is being filled in by our WEbsphere portal server.
When the log size gets to say 1GB we want to back it up in another directory and empty the current log file.
Therefore basically we are doing:
cp SystemOut.log <some dir with large space>
cat /dev/null > SystemOut.log
I have done it about 3 times and out of that once it caused problems which basically were that the portal server wouldnt write anything in the log file after cat /dev/null. And we had to eventually restart the portal server.
So basically my question is that can you see anything wrong with what we are trying to do here and can you suggest an alternate way of doing it?
What about the command: "> SystemOut.log" ?
many thanks
ali
- 08-18-2008 #2
Hello,
some time ago, I had a similar problem. The problem was, that the logging application was proprietary software, so I could not improve it so that it closes and moves the logfile at a given size, what would have been the most straightforward way to deal with it.
My workaround was to create a FIFO with the name of that logging file. So the software wrote to that fifo, assuming it had been an ordinary file. On the other end of that FIFO was an application I wrote, write anything from that FIFO to a separate file. This way, it was under my control finally.
- 08-18-2008 #3Just Joined!
- Join Date
- Jun 2007
- Location
- UK
- Posts
- 14
Hi mate sounds like a really good idea.
Can you please explain the FIFO a bit more? with some sample code if possible.
thanks
ali
- 08-18-2008 #4Linux Guru
- Join Date
- Nov 2004
- Posts
- 6,110
You can also use a redirect to just empty a file.
Remember that this way you are limiting the size of the content used to overwrite the file. You could for instance output a string letting you know when you overwrote the fileCode:echo > SystemOut.log
Code:echo File overwritten at $(date) > SystemOut.log
- 08-18-2008 #5
It isn't really that different from how you deal with ordinary files. You create a FIFO with mkfifo and give it a name, lets say "/home/logger/testfifo". Your application then opens this like it was an ordinary file and reads it line by line.
When nothing has written to this fifo, your application it put to sleep by the OS until something does.
The other application uses this fifo as the file to log to.
Maybe a short game to explain it:
- Open two terminals.
- In terminal one write "mkfifo testfifo". And then "cat testfifo". Cat will sleep until someone else writes to that fifo.
- In terminal two write echo "Hello" > testfifo. It should come out of the wormhole's other end.
- rm testfifo deletes the fifo when you are done with it
Read "man 3 mkfifo" and "man mkfifo".
- 08-20-2008 #6Just Joined!
- Join Date
- Jun 2007
- Location
- UK
- Posts
- 14
The idea of FIFO is good but i dont think would be applicable to my problem as i cant force the 3rd party application to write its logs into this fifo file.
cheers


Reply With Quote
