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

Previous

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable