# How to make the log file printed by access\_log split

**URL:** <https://www.ruby-forum.com/t/how-to-make-the-log-file-printed-by-access-log-split/235940>\
**Category:** NGINX\
**Created:** [July 25, 2013, 10:53am UTC](https://www.ruby-forum.com/t/how-to-make-the-log-file-printed-by-access-log-split/235940 "2013-07-25T10:53:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 25, 2013, 10:53am UTC](https://www.ruby-forum.com/t/how-to-make-the-log-file-printed-by-access-log-split/235940/1 "2013-07-25T10:53:01Z")

</div>

what’s the limit of the size of log file, and what will happen when it  
reaches the limitation?  
if I want to split the log file by timeline, say start a new file on the  
beginning of an hour, how can I configure ngnix?

thanks

Posted at Nginx Forum:

> **[How to make the log file printed by access\_log split](https://forum.nginx.org/read.php?2,241226,241226#msg-241226)**
>
> what's the limit of the size of log file, and what will happen when it reaches the limitation? if I want to split the log file by timeline, say start a new file on the beginning of an hour, how can I configure ngnix? thanks

---

<div class="post-metadata">

**Author:** ![shawnxzhou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ea666f/32.png) [@shawnxzhou](https://www.ruby-forum.com/u/shawnxzhou)\
**Post date:** [July 25, 2013, 11:29am UTC](https://www.ruby-forum.com/t/how-to-make-the-log-file-printed-by-access-log-split/235940/2 "2013-07-25T11:29:51Z")

</div>

Hello!

On Thu, Jul 25, 2013 at 04:52:38AM -0400, shawnxzhou wrote:

> what’s the limit of the size of log file, and what will happen when it  
> reaches the limitation?  
> if I want to split the log file by timeline, say start a new file on the  
> beginning of an hour, how can I configure ngnix?

This isn’t something nginx is expected to do. Instead, this is  
what your favorite log rotation program does, and then uses USR1  
signal to instruct nginx to reopen log files, see [1]. Consult  
your OS documentation for more details, usually “man newsyslog” or  
“man logrotate” helps.

[1] [Controlling nginx](http://nginx.org/en/docs/control.html#logs)

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![shawnxzhou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ea666f/32.png) [@shawnxzhou](https://www.ruby-forum.com/u/shawnxzhou)\
**Post date:** [July 25, 2013, 11:40am UTC](https://www.ruby-forum.com/t/how-to-make-the-log-file-printed-by-access-log-split/235940/3 "2013-07-25T11:40:23Z")

</div>

Hi  
There’s no size limit, it will keep getting bigger until your disk is  
full  
Here’s a script I use to rotate the log, run it from cron every hour  
hope it helps

#!/bin/sh  
PID=`cat /usr/local/nginx/logs/nginx.pid`  
LOG="/usr/local/nginx/logs/access.log"  
NOW=$(date +"%Y-%m-%d-%H-%M")  
NEWLOG="${LOG}.${NOW}  
mv ${LOG} ${NEWLOG}  
kill -USR1 ${PID}  
gzip ${NEWLOG}
