Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Can logrotate apply multiple rotate rules?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: Can logrotate apply multiple rotate rules?

#16 Post by PsySc0rpi0n »

sickpig wrote:so whats stopping you from using systemd.timer as opposed to cron?
I had this working with cron in that past. I see no need to change it now. I want to keep the thread focused in cron and logrotate if possible. After I get this working, I may try systemd.time or whatever that is.

But in the meantime, I read a bit more and did the follwoing:

Created a file named 'myfile' in:

Code: Select all

/etc/logrotate.d
and set the following configs in it for logrotate:

Code: Select all

/media/wdelements/debug.log {
    rotate 5
    daily
    copytruncate
    size 50M
    dateext
    dateformat -%d%m%Y
    maxage 31
}
Then, I created a bah script inside

Code: Select all

/etc/cron.hourly
With the following content:

Code: Select all

#!/bin/bash

if [ -f /etc/logrotate.d/myfile ]; then
	logrotate --verbose /etc/logrotate.d/myfile
else
	echo "File not found!"
fi
And despite logrotate is set to run daily by default, I think this should do the trick, no?

User avatar
PsySc0rpi0n
Posts: 322
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: Can logrotate apply multiple rotate rules?

#17 Post by PsySc0rpi0n »

I'm reviving this thread of mine.

In the meantime I had to re-install my Debian due to some hardware problems. I bought a new SSD because the old was was with hardware failures.
So, this said, I'm again trying to setup logrotate and cron/anacron. But I'm not sure I have this correctly set.

With anacron installed, cron jobs are kind of over ruled by anacron, if I understand correctly.

So, I added a file in /etc/logrotate.d/my-rotate-rules telling the rules I want for the file in question and I verified that inside /etc/anacrontab there are entreies to run cron jobs daily, weekly and monthly. So, I presume this is all I need.

Am I correct?

Edited:

I didn't remember my last post in this thread. I'll try to replicate it.

Post Reply