0

I use pyapns (Iphone push server) which in turn uses twisted (twistd daemon).

twistd daemon produces twistd.log files. It rotates them to twistd.log.1, twistd.log.2 and so on when twistd.log reaches 1MB but it doesn't use logrotate so I guess it's built in.

The problem is that this continues forever and that old log files are never deleted. This eventually fills my disk.

I've tried to use logrotate or similar to rotate the logs, but then I would need to run logrotate very very often since I need to rotate BEFORE twistd.log reaches 1MB. This could happen within a second for all I know depending on how much log is produced.

So how could I logrotate without hacking pyapns/twistd scripts?

1 Answer 1

1

There isn't really a way to do it with regular logrotate. Logrotate is not a daemon, it's run by cron, and usually once per day.

You can change it to run every few seconds, but if the 1MB can fill up so fast, there's no way logrotate could keep up.

Why don't you write a simple cron job that would delete all the excess of rotated log files, and leave it to pyapns/twistd to continue to rotate at 1MB? For example you could delete all files older then a week, with a simple cron job like this:

/usr/bin/find /var/log/twistd/* -mtime +7 -exec /bin/rm {} \;

You can even compress the files, with something like:

/usr/bin/find /var/log/twistd/* -regex '*.log.[0-9]+' | /usr/bin/xargs -I{} /bin/gzip {}

That way you could simulate logrotate behaviour without having to turn off Twistd internal logrotate, and without a risk of disk filling up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .