Re: leading null characters produced in script...
- From: Unruh <unruh-spam@xxxxxxxxxxxxxx>
- Date: 30 Oct 2006 20:54:26 GMT
Paul Colquhoun <postmaster@xxxxxxxxxxxxxxxxxxxx> writes:
On 29 Oct 2006 22:54:56 -0800, Avalon1178 <Avalon1178@xxxxxxx> wrote:
| Hello,
|
| I'm trying to write a small script using bash that essentially archives
| logs to prevent logs from getting too big and take up drive space. The
| way I do it, when a log file reaches a certain size, I have an external
| script that copies that log file to another file, truncates to 0 length
| the original log file, and let the the other script that generates the
| log continues on. The problem I'm having is I'm getting leading null
| characters at the beginning of the new log, which sometimes takes too
| many bytes which triggers my log archiver prematurely.
|
| For example, here's is my (simplified) log archiver script written in
| bash:
|
| while [1]; do
| if [ -a $logFile ]; then
| logSize=$(stat -c%s $logFile);
| if [ $logSize -ge 5000 ]; then
| cp $logFile $logFile.arch
| cat /dev/null >$logFile
| fi
| fi
| done
I think you need 'cp /dev/null $logFile' instead of 'cat'.
iAll you need is
>$logfile
--.
Reverend Paul Colquhoun, ULC. http://andor.dropbear.id.au/~paulcol
Asking for technical help in newsgroups? Read this first:
http://catb.org/~esr/faqs/smart-questions.html#intro
- References:
- leading null characters produced in script...
- From: Avalon1178
- Re: leading null characters produced in script...
- From: Paul Colquhoun
- leading null characters produced in script...
- Prev by Date: Re: leading null characters produced in script...
- Next by Date: Re: Knoppix - ssh connection refused.
- Previous by thread: Re: leading null characters produced in script...
- Next by thread: Re: leading null characters produced in script...
- Index(es):
Relevant Pages
|