LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-13-2011, 05:15 AM   #1
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Rep: Reputation: 33
Rotate logfiles multiple times a day


Hello,

how can I rotate logfiles multiple times a day ?

I notice that the configuration for the logrotate-command is hourly, daily, weekly,...

I notice that I can create a cron job where I specify the different times the log rotation need to be done :
15 0,8,12,17 * * *

But how do I combine these two ?
 
Old 03-13-2011, 06:08 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
To force the logs to be rotated, you can use
Code:
logrotate -f -s -d /etc/logrotate.conf
Kind regards
 
Old 03-13-2011, 06:17 AM   #3
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by repo View Post
To force the logs to be rotated, you can use
Code:
logrotate -f -s -d /etc/logrotate.conf
Kind regards
And so it does not matter what is defined in logrotate.conf ?? Whether daily or weekly is set in logrotate.conf does not matter when I use a crontab ?
 
Old 03-13-2011, 06:20 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
Quote:
And so it does not matter what is defined in logrotate.conf ?? Whether daily or weekly is set in logrotate.conf does not matter when I use a crontab ?
No, it will rotate the logs specified in the logrotate.conf file.

Quote:
-f, --force
Tells logrotate to force the rotation, even if it doesn't think this is necessary. Sometimes this is useful after adding new entries to a logrotate config file, or
if old log files have been removed by hand, as the new files will be created, and logging will continue correctly.
Kind regards

Last edited by repo; 03-13-2011 at 06:21 AM.
 
Old 03-13-2011, 06:27 AM   #5
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Will the "rotate daily" or "rotate weekly" command in logrotate.conf be executed also ?!

So in other words, will I have at the end of the week an extra rotate ?
 
Old 03-13-2011, 06:37 AM   #6
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
Quote:
So in other words, will I have at the end of the week an extra rotate ?
Only if the logfile meets the values, set in logrotate.conf or in the logrotat.d directory,
like size etc.

Kind regards
 
Old 03-13-2011, 03:16 PM   #7
jonaskellens
Member
 
Registered: Jul 2008
Location: Ghent, Belgium
Distribution: Fedora, CentOS
Posts: 632

Original Poster
Rep: Reputation: 33
Quote:
Originally Posted by repo View Post
Only if the logfile meets the values, set in logrotate.conf or in the logrotat.d directory,
like size etc.
So if the value "rotate weekly" is set in logrotate.conf, then at the end of the week I will have an extra rotation ?

Can I omit the "rotate" value ?!
 
Old 03-13-2011, 03:25 PM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
Quote:
So if the value "rotate weekly" is set in logrotate.conf, then at the end of the week I will have an extra rotation ?
If it meets the values, like size etc
It will only rotade if the size is > then x,or if the log is older then x
But since you are going to rotate several times a day, the weekly and monthly rotation doesn't matter anymore.


Kind regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to make a URL available only during certain times of day scolesworthy Linux - General 6 11-13-2010 09:55 PM
upload and rotate multiple pictures for webapp paranoid times Linux - Software 3 01-27-2009 04:28 PM
System freezes a couple of times a day Fugazi Fedora 12 01-02-2009 06:44 PM
My Logfiles have inconsistent times and dates! ille.pugil42 Linux - Software 2 03-14-2007 01:10 PM
iptables : Restrict access at certain times of day J-Ben Linux - Newbie 1 03-28-2004 10:38 PM


All times are GMT -5. The time now is 09:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration