how to logrotate log files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users how to logrotate log files
# 1  
Old 10-21-2009
Java how to logrotate log files

Hi,
I have written a script that runs every five minutes in cron schedular. The Operating system is Fedora core 9. This script generates 2 log files, these log file size is increasing as some log data is being dumped into these 2 log files every five minutes. I need to logrotate these 2 files. Could someone help me with the steps to configure logrotate for the 2 files?
Thanks in advance
# 2  
Old 10-21-2009
re: how to logrotate files

If you have logrotate installed (chances are you do) then there should be a few files in /etc/logrotate.d that you can look at to give examples of how to use logrotate to do daily log rotations. The format is fairly straighforward - the names of the files to be rotated, follwed by a list of configuration options in {}. The /etc/logrotate.conf file contains system wide defaults.

Look at the man pages (man logrotate) to find out what the options mean and pay particular attention to the 'create' and 'copytruncate' sections. Since your script is running out of cron you likely don't need to worry about signaling it to start a new log file, however you will want to be careful about what would happen if logrotate runs at the same time as your script.

Logrotate itself is called by cron once per day so if you need more frequent log rotation you'll need to set that up manually. You can look at the /etc/crontab file to find out when the scripts in /etc/cron.daily folder are going to be run. (That's where logrotate is called)

Cheers,
Anthony
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Logrotate and Compressing only yesterdays files

Hello, I have a syslog server at home and am currently experiencing an issue where my logs will rotate and compress however it will rotate and compress yesterdays file and the newly created log file for the current day. When it does this however it will also create another new file for today... (9 Replies)
Discussion started by: MyUserName7000
9 Replies

2. UNIX for Beginners Questions & Answers

Logrotate exclude log file

Hi all ! I've an issue to exclude a log file from logrotate, I tried this below: /var/log/apache2/*.log { olddir /var/log/apache2/old missingok rotate 50 compress copytruncate notifempty create 644 root root } I tried also:... (0 Replies)
Discussion started by: Arnaudh78
0 Replies

3. 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

4. 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

5. Shell Programming and Scripting

Help needed on Perl Script to Handle Log files that are rotated using logrotate

Hello all, I am working on a perl script which will read weblogic logfile and send the error messages to Zenoss Monitoring tool. At present the script works and it can able to send the error messages to Zenoss. The problem comes when the logrotate has been applied to the weblogic log file. At... (3 Replies)
Discussion started by: kar_333
3 Replies

6. Debian

Logrotate truncated my log files to 0 bytes and no logs are written

Hi, Yesterday I installed and configured logrotate on my Debian machine. I was expecting this to run at 06:25 in the morning and it actually did. All my old logs were compressed and zipped but the new logs were all with size equal to 0 bytes. Processes, while still running ok, they were not... (2 Replies)
Discussion started by: pmatsinopoulos
2 Replies

7. Red Hat

Logrotate not removing old files

Hi Guys, Need some help with the logrotate for one of our servers. I had setup a logrotation so that all files that go under old/ folder should be removed after one week. The log files are rotated daily from the main folder to old/ folder. (everything on one server) Below is the sample I am... (0 Replies)
Discussion started by: rockf1bull
0 Replies

8. Linux

Using logrotate to trim files that are created every 15 mins

I have an application (puppet) that generates report files every 15 minutes in the format: /var/lib/puppet/reports/hostname.fqdn/report-201007221515.yaml /var/lib/puppet/reports/hostname.fqdn/report-201007221530.yaml .. I only really need to keep one days worth of these reports and am trying... (0 Replies)
Discussion started by: aussieos
0 Replies

9. 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

10. UNIX for Advanced & Expert Users

logrotate isn't rotating files any longer

I have been using logrotate for quite awhile now. Most logs are rotated daily, using /etc/cron.daily. I noticed that the logs in question have not been rotated since April 6, but daily up to that point. I have logrotate in /etc/cron.daily. The basic command is: /usr/sbin/logrotate... (1 Reply)
Discussion started by: manouche
1 Replies
Login or Register to Ask a Question