1819814 Members
2735 Online
109607 Solutions
New Discussion юеВ

Re: Scheduling logrotate

 
Raynald Boucher
Super Advisor

Scheduling logrotate

Good day all,

Where and how do you tell logrotate which day to perform weekly or monthly rotations?
Is there a separate parameter file or do you have to schedule it at different times with different configuration files.

We run logrotate daily via cron and the weeklies are performed on Sunday. I beleive the default for monthly would be the 1st of the month.
What if you want to rotate logs on the first Sturday of the weekl or the first non business day of the month?

Thanks
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: Scheduling logrotate

Just change the cron schedule

logroate is custom, I've never heard of it before. I wrote my own.

man cron

The third column on cron times is day iof the month.

To have your logroate run on the first day of the month at 4 14 am it looks like this

15 4 1 * * /usr/contrib/bin/logroate

Let me know if I need to elaborate further.

The system will rotate logs on its own, perhaps thats a program called logrotate, I've not bothered to check. Mine get to big, so I do it more often.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Martin P.J. Zinser
Honored Contributor

Re: Scheduling logrotate

Well, looking at the man page on my SuSE system it seems that this is a Redhat package ;-)

The explanation for monthly is pretty clear:

monthly
Log files are rotated the first time logrotate is
run in a month (this is normally on the first day
of the month).

One way around this might be to break your daily, weekly, and monthly logrotate activities out to different configuration files and shedule these independently using cron.

Greetings, Martin


Vitaly Karasik_1
Honored Contributor

Re: Scheduling logrotate

I almost sure there is some option in logrotate config itself in order to do what you want.

Rgds,
Vitaly
Robert Binkhorst
Trusted Contributor

Re: Scheduling logrotate

Hi,

From the logrotate manual:
monthly
Log files are rotated the first time logrotate is run in a month (this is normally on the first day of the month).

That means that if you're running a RedHat installation logrotate is scheduled every day:
/etc/cron.daily/logrotate

All this does is run logrotate with a config file, /etc/logrotate.conf.
You can easily fix your problem as follows:
- move the monthly config files from /etc/logrotate.d/ directory (or they will still be run on a normal schedule), place them in /etc/logrotate_monthly.d/,
- create a new config file /etc/logrotate_monthly.conf and point the include to /etc/logrotate_monthly.d/.
- Remove any parts not owned by any package.

Now schedule this new logrotate process to run whenever you want it to, using crontab for instance.
linux: the choice of a GNU generation
Raynald Boucher
Super Advisor

Re: Scheduling logrotate

So I gather there is no hidden parameter file and "non standard" rotations must be scheduled otherwise.

Thanks for the answers.
Steven E. Protter
Exalted Contributor

Re: Scheduling logrotate

logroate -f

for force, meaning rotate now.

You can have your cron daemon run logrotate with the -f parameter on any schedule you set(see my first post on cron).

I didn't know that until I researched your thread.

There seems to be no underlying parameter file.

cron is a good enough tool to run logroate more often. I'm probably going to switch my log rotation script to run logroate instead for the sake of simplicity.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com