logrotate - why ignore size ?


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu logrotate - why ignore size ?
# 1  
Old 10-11-2009
logrotate - why ignore size ?

Hi, i have a logroate script that works properly when running manually but otherwise it won't work.I put in in /etc/logrotate.d/nginx. I simply cannot understand why it won't run properly when run with a cronjob. It suppose to run hourly and rotate logs if they are > 3mb. What am i missing here ?:

Code:
/home/*/log/*log {
    hourly
    rotate 2
    dateext
    missingok
    notifempty
    create 0644 root webmasters
    sharedscripts
    postrotate
    size 3M
        kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
    endscript
}

My logrotate.conf
Code:
# see "man logrotate" for details
# rotate log files daily
daily

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create 0644 webmasters

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

/var/log/btmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

# system-specific logs may be configured here

# 2  
Old 10-11-2009
Quote:
Originally Posted by ktm
Hi, i have a logroate script that works properly when running manually but otherwise it won't work.I put in in /etc/logrotate.d/nginx. I simply cannot understand why it won't run properly when run with a cronjob. It suppose to run hourly and rotate logs if they are > 3mb. What am i missing here ?:
How do you know it's running properly when run manually? Did you check the output of either of these:
Code:
logrotate -d /etc/logrotate.conf # run in debug mode
logrotate -v /etc/logrotate.conf # run with verbose messages

Other than that I see 2 possible problems with your configuration:
Code:
/home/*/log/*log {
[...]
    create 0644 root webmasters
    sharedscripts
    postrotate
    size 3M
        kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
    endscript
}

Those 2 lines definitely have to be swapped.

logrotate.conf
Code:
[...]
# This doesn't belong in the global configuration, but in the
# per-log rules.
# create new (empty) log files after rotating old ones
create 0644 webmasters

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Logrotate - /etc/logrotate.conf does't exist

Hi Admins. I have installed logrotate rpm on Aix 6.1. After the installation of rpm, I don't find /etc/logrotate.conf file and /etc/logrotate.d dir . The config file is located in /opt/freeware/etc/logrotate.conf. When I ran logrotate -v /opt/freeware/etc/logrotate.conf I get below... (2 Replies)
Discussion started by: snchaudhari2
2 Replies

2. Shell Programming and Scripting

Logrotate - I am not able to rotate files using logrotate

I have written script which is working in Home directory perfectly and also compressing log files and rotating correctly. But, when i try to run script for /var/log/ i am able to get compressed log files but not able to get rotation of compressed log files. Please suggest. I am using below command... (5 Replies)
Discussion started by: VSom007
5 Replies

3. SuSE

Which logs to logrotate?

Hi all We've had new servers coming in and one of the requirement was to keep logs for up to 8 months. I know logrotate can do the job, but by default (on Suse Enterprise10, 11) we have these logs in /etc/logrotate.d dir as default logs which are rotated: -rw-r--r-- 1 root root 140 Jul... (0 Replies)
Discussion started by: hedkandi
0 Replies

4. UNIX for Dummies Questions & Answers

logrotate ignore 'rotate' setting.

the 'rotate' setting in my logrotate configurations is being ignored when run from the crontab. I have tested my configurations using the "-d" option, the rotation count is working when I do the test. Here are my configuration settings, is there anything I am doing wrong? # cat -n... (5 Replies)
Discussion started by: frankkoenen
5 Replies

5. Shell Programming and Scripting

logrotate irrespective of the size of a file/directory

hi, How to logrotate irrespective of the size of a file/directory...? Please help me in this regard... (4 Replies)
Discussion started by: Dedeepthi
4 Replies

6. Linux

LogRotate

Hi I am trying to rotate specific log by using logrotate function in unix I have made following entry in the /etc/logrotate.conf file /var/log/testlog/debug_log { daily rotate 7 create compress } But only issue is that my other logs like /var/log/messages,... (2 Replies)
Discussion started by: SiddhV
2 Replies

7. UNIX for Advanced & Expert Users

logrotate with /etc/logrotate.conf file

Hi there, I want to rotate the logfiles which are located in /var/log/jboss/tomcat* so I have created a file named as 'tomat' in /etc/logrotate.d/tomcat with the following content. # cat /etc/logrotate.d/tomcat /var/log/jboss/tomcat_access_log*.log { daily nocreate ... (2 Replies)
Discussion started by: skmdu
2 Replies

8. UNIX for Advanced & Expert Users

logrotate size limit

Hi i configured log rotate for a specific file. /var/log/sauer i configured create a file in logrotate.d # cat /etc/logrotate.d/sauer #this is a logrotate configuration file for msu_ng logs /var/log/sauer { rotate 5 size=1M daily compress ... (5 Replies)
Discussion started by: modcan
5 Replies

9. UNIX for Advanced & Expert Users

logrotate bug?

I have been mailing myself logs for a while, but just ran into a problem because of a process that cannot HUP its log. (I realize thats why they implemented the "copytruncate" option in the first place) When I use logrotate with "copytruncate" and "compress" there is a problem. The "myScript"... (0 Replies)
Discussion started by: jjinno
0 Replies

10. UNIX for Dummies Questions & Answers

how to set size in logrotate.conf

Hi,guys: recently,i am puzzled by a question .when i create a new file named by /etc/logrotate.d/debug. The cont. is listed as follow: /var/log/debug { rotate 3 missingok notifempty size=2k prerotate /bin/kill -HUP `cat... (0 Replies)
Discussion started by: icehero
0 Replies
Login or Register to Ask a Question