0

I have a daemon script I made that always runs in the background. It's setup to pipe stdout and stderr to some log files as such:

python27 etl_daemon.py 1>>/var/log/etl/etl_stdout.log 2>>/var/log/etl/etl_stderr.log

I have logrotate setup on those log files with the configuration for each basically being:

$ cat /etc/logrotate.d/etl_stdout
/var/log/etl/etl_stdout.log {
daily
rotate 14
compress

logrotate definitely works in terms of zipping and renaming old logs, but it looks like every time it runs it busts my script and leaves it running but no longer doing anything. I'm guessing this might have something to do with trying to write to a file that's now been renamed, but I'm not sure. Ideas? Solutions?

1

Add the copytruncate directive to your logrotate stanza. Then the file won't be pulled out from under your daemon.

When you do that, be sure to write in append mode (as you have in your example), otherwise you'll end up with sparse files after rotation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.