Log file rotation script
Aníbal Rojas
anibalrojas at gmail.com
Tue Jun 10 14:40:14 MSD 2008
AmI missing something or using logrotate as Corey is just fine?
(I use logrotate for everything)
--
Aíbal
On Sun, Jun 8, 2008 at 9:37 PM, Dave Cheney <dave at cheney.net> wrote:
> I wrote this a while ago which does the trick
>
> #!/bin/bash
>
> YEAR=`date "+%Y"`
> MONTH=`date "+%m"`
> DAY=`date "+%d"`
>
> HOSTNAME=`hostname -s`
>
> LOG_FILES="access.log error.log"
>
> DATE=$YEAR/$MONTH/$DAY
>
> LOG_ROOT=/var/log
> NGINX_LOG_ROOT=$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`
>
>
>
>
> On 09/06/2008, at 11:50 AM, Rt Ibmer wrote:
>
>> Hi - does anyone have a log file rotation script for nginx they can share?
>> Basically just looking for something simple I can set up in cron once a day
>> that will tell nginx to roll the log file and set its file name to the
>> current date, and then gzip it. Thanks!
>>
>>
>>
>>
>>
>>
>
>
>
--
Aníbal
More information about the nginx
mailing list