Can logrotate apply multiple rotate rules?

New to Debian (Or Linux in general)? Ask your questions here!

Re: Can logrotate apply multiple rotate rules?

Postby PsySc0rpi0n » 2020-06-13 11:52

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: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: Can logrotate apply multiple rotate rules?

Postby PsySc0rpi0n » 2021-02-09 19:44

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.
User avatar
PsySc0rpi0n
 
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Previous

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 10 guests

fashionable