You are not logged in.

#1 2010-01-13 23:19:46

anti-destin
Member
Registered: 2009-02-14
Posts: 234

[solved] crontab and logrotate

i'm trying to configure when logrotate runs. i created a text file called clearlog with the following content:

# rotate logs
09 17 * * * root /usr/sbin/logrotate -f /etc/logrotate.conf >/dev/null 2>&1

i then placed it in /etc/cron.d.

but the logs weren't rotated at 5.09pm, even though they should have been given the details in logrotate.conf.

did i make a mistake somewhere?

Last edited by anti-destin (2010-01-15 14:48:47)

Offline

#2 2010-01-13 23:24:03

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [solved] crontab and logrotate

You might want read http://bugs.archlinux.org/task/16085  + discussion on the mailing lists  smile


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#3 2010-01-13 23:44:40

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [solved] crontab and logrotate

You might also have a look at metalog, which has log-rotating functionality built in.

Offline

#4 2010-01-14 00:26:29

anti-destin
Member
Registered: 2009-02-14
Posts: 234

Re: [solved] crontab and logrotate

Mr.Elendig wrote:

You might want read http://bugs.archlinux.org/task/16085  + discussion on the mailing lists  smile

thanks for the information. i didn't realize dcron didn't look in /etc/cron.d.

lucke wrote:

You might also have a look at metalog, which has log-rotating functionality built in.

thanks. i'll check it out.

i went ahead and edited my user crontab. i added this:

# rotate logs
20 18 * * * /usr/sbin/logrotate -f /etc/logrotate.conf >/dev/null 2>&1

(i took out the user and changed the time to test it.)

again, the files weren't rotated. is there a mistake in my crontab?

Last edited by anti-destin (2010-01-14 00:27:20)

Offline

#5 2010-01-14 02:48:26

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: [solved] crontab and logrotate

You edited your user's or root's crontab? Obviously, your user doesn't have permission to rotate logs.

Do you need all this? There's logrotate in /etc/cron.daily/.

Offline

#6 2010-01-14 04:01:11

anti-destin
Member
Registered: 2009-02-14
Posts: 234

Re: [solved] crontab and logrotate

thank you, lucke! all i needed to do was edit the root crontab and change cron.daily time.

Offline

#7 2010-01-14 08:01:37

Profjim
Member
From: NYC
Registered: 2008-03-24
Posts: 658

Re: [solved] crontab and logrotate

The existing version of dcron already does do /etc/cron.d stuff. I don't know why some people are having trouble with it, ore reporting this functionality as something dcron "doesn't do". (There was a point where dcrond didn't do it, but that was a long time ago.)

In any case, I took over development of dcron with the 4.x series, which is now in [testing], and this should handle /etc/cron.d fine. Complain to me if it doesn't.

In this case, I think logrotate will only rotate logs at most once a day unless you force it. Perhaps your second cron job was calling logrotate but logrotate wasn't doing anything because it had already run?

Offline

#8 2010-01-14 18:14:50

anti-destin
Member
Registered: 2009-02-14
Posts: 234

Re: [solved] crontab and logrotate

thanks for the information, profjim. it was most likely a permissions issue. (i used the -f switch, so logrotate should have run.)

in any case, editing the root crontab is a better solution. it's far simpler and doesn't require that files be added to cron.d.

Offline

Board footer

Powered by FluxBB