Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am considering Tux as the web server for a new CPAN mirror I'm building. I've got it running and it's very fast but there is one big catch: how am I supposed to rotate the log file?

The log file is configurable, and I am using the default value of /var/log/tux.

One option would be copy-and-truncate; e.g.:

cp /var/log/tux /var/log/tux.1
cat /dev/null > /var/log/tux

The logrotate application can do that for me but since the log file is binary I am concerned that this might lead to corruption at some point.

If it only corrupts one entry I can live with it - my fear is that the whole log file could be lost.

Anyone with experience care to make a suggestion?

Thanks

share|improve this question

3 Answers 3

up vote 0 down vote accepted

You could try something like this, which I wrote to roll my nginx logs. I looked for some details on the tux userspace process but couldn't find any way to get it to reopen it's logs, so you may have to resort to stopping and starting the process.

#!/bin/bash

YEAR=`date "+%Y"`
MONTH=`date "+%m"`
DAY=`date "+%d"`

HOSTNAME=`hostname -s`

LOG_FILES="access.log error.log images.log redirect.log ssl.log click.log uploads.log urchin.log user_sites.log"

DATE=$YEAR/$MONTH/$DAY

LOG_ROOT=/var/log/
NGINX_LOG_ROOT=$NGINX_LOG_ROOT/nginx

# make path

mkdir -p $NGINX_LOG_ROOT/$DATE

# touch and symlink in new log files

for FILE in $LOG_FILES; do
    LOG_FILE=$NGINX_LOG_ROOT/$DATE/$HOSTNAME.$FILE
    touch $LOG_FILE
    ln -fs $LOG_FILE $NGINX_LOG_ROOT/$FILE
done

# tell nginx to re-open its log files

kill -USR1 `cat /var/run/nginx.pid`
share|improve this answer
    
I don't need the date archiving stuff but it does seem to me that the way to go is to rotate and restart Tux. Another way would be to change the log name via /prox/sys/net/tux/ but I haven't tested to check if it will start writing to the newly changed log path without a restart. –  XCondE Jun 20 '09 at 2:41

Before I suggest something "TUX has never been an integrated part of the official Linux kernel". Are you sure you want to maintain kernel patches on your own?

Personally I'd try to create a pipe which tux writes to and then use rotatelogs (from apache) to handle that stuff. Maybe even logger so that it uses syslog directly.

rotatelogs can handle time or size based rotations for you, if you don't send the logs to a central logging server I'd use that, if you do send to a central logging server I'd send it to syslog, just let syslog create another socket which tux will write to (preferrably /var/log/tux), and syslog should handle the rest for you...

share|improve this answer
    
Sorry, I didn't mention we're running Red Hat Enterprise Linux. RH provides the Tux kernel module and user-land stuff so maintaining it is as simple as "yum install tux" and "yum update". –  XCondE Jun 19 '09 at 21:45

I'm a bit curious here: What do you expect of incoming requests per second since you need a HTTP engine running inside your kernel? Isnt tinyhttpd fast enough?

share|improve this answer
    
It may be - I'm not sure RH provides an RPM package for it though. –  XCondE Jun 19 '09 at 21:46
    
RH does not provide packages for tinyhttpd. To answer your question, I'm not expecting a huge demand on the server but I would like to keep the memory and CPU footprint low. –  XCondE Jun 19 '09 at 21:51
    
Well, tiny httpd is extremely cheap on resources. Perhaps you should give it a try? I would try anything but running something inside the kernel. Here are the instructions posted on the tiny httpd website: On Red Hat Linux systems you can use RPM to install thttpd, like so: cd /usr/src/redhat/SOURCES wget acme.com/software/thttpd/thttpd-2.25b.tar.gz rpm -ta thttpd-2.25b.tar.gz rpm -i /usr/src/redhat/RPMS/i386/thttpd-2.25b-1.i386.rpm –  pauska Jun 19 '09 at 23:30
    
Ok, that looks awful. acme.com/software/thttpd - scroll a bit down. –  pauska Jun 19 '09 at 23:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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