Nginx and logrotate
Sergey Kobzar
sergey.kobzar at itcraft.org
Thu Aug 8 08:36:11 UTC 2013
On 08/08/13 10:43, Boris Talovikov wrote:
>>>> cat /etc/logrotate.d/nginx
>>>> /var/log/nginx/*.log {
>>>> daily
>>>> rotate 5
>>>> missingok
>>>> nocompress
>>>> sharedscripts
>>>> postrotate
>>>> test -r /run/nginx.pid && kill -USR1 `cat
>>>> /run/nginx.pid`
>>>> endscript
>>>> }
>>>
>>> У вас PID файлы точно в /run ? Обычно это /var/run
>>
>> Угу:
>>
>> # la /var/run
>> lrwxrwxrwx 1 root root 4 Jan 23 2013 /var/run -> /run
>>
>> # ps ax | grep nginx
>> 1965 ? Ss 0:00 nginx: master process /usr/sbin/nginx -c
>> /etc/nginx/nginx.conf
>> 1966 ? S 35:55 nginx: worker process
>> 1967 ? S 35:37 nginx: worker process
>> 1969 ? S 35:08 nginx: worker process
>> 1970 ? S 34:57 nginx: worker process
>> 1971 ? S 34:55 nginx: worker process
>> 1972 ? S 35:12 nginx: worker process
>> 1973 ? S 35:11 nginx: worker process
>> 1974 ? S 36:01 nginx: worker process
>>
>> # cat /run/nginx.pid
>> 1965
>>
>>
>>>> Сегодня утром получил сообщение от cron'а:
>>>> gzip: stdin: file size changed while zipping
>>>> gzip: stdin: file size changed while zipping
>>>>
>>>> Но так, как в /etc/logrotate.d/nginx есть nocompress, то есть
>>>> подозрение, что это общесистемное.
>>>>
>>>> Any ideas?
>>
>> _______________________________________________
>> nginx-ru mailing list
>> nginx-ru at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
> Здравствуйте, а можно увидеть вывод команды
>
> logrotate -d /etc/logrotate.conf ?
Ну вот сегодня отротировалось все нормально:
-rw-r--r-- 1 nginx root 268M Aug 8 11:32 access.log
-rw-r--r-- 1 nginx root 1.2G Aug 3 03:10 access.log-20130803
-rw-r--r-- 1 nginx root 1.1G Aug 4 03:10 access.log-20130804
-rw-r--r-- 1 nginx root 2.5G Aug 6 03:10 access.log-20130805
-rw-r--r-- 1 nginx root 2.5G Aug 8 01:31 access.log-20130807
-rw-r--r-- 1 nginx root 20M Aug 8 03:10 access.log-20130808
# logrotate -d /etc/logrotate.conf
reading config file /etc/logrotate.conf
including /etc/logrotate.d
reading config file elog-save-summary
reading config file exim
reading config file munin
reading config file mysql
reading config file nginx
reading config file openrc
reading config file php-fpm
reading config file rsyncd
reading config file sphinx
reading config file syslog-ng
Handling 15 logs
...
rotating pattern: /var/log/nginx/*.log after 1 days (5 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/nginx/default-ssl_access.log
log does not need rotating
considering log /var/log/nginx/default-ssl_error.log
log does not need rotating
considering log /var/log/nginx/access.log
log does not need rotating
considering log /var/log/nginx/error.log
log does not need rotating
Ротацию логов для других сервисов поскипал.
Подробная информация о списке рассылки nginx-ru