HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Logrotate Problem in cron daemon

 
Muhib Tanim
Occasional Visitor

Logrotate Problem in cron daemon

Hi

/opt/logrotate/bin/logrotate logrotate.conf executes successfully and fulfill my target, which compressed the old logs.
but when I try to execute same command through cronjob it executes but not compressed only take the backup of old logs.
Then I execute a script through cron, where command and profile execution done.

Any one faced same type of problem before.
6 REPLIES
Pete Randall
Outstanding Contributor

Re: Logrotate Problem in cron daemon

Take a look at logrotate to see if the portion that is supposed to compress the old logs identifies the full path name of whatever command it is using.


Pete

Pete
OldSchool
Honored Contributor

Re: Logrotate Problem in cron daemon

most likely, this is related to a pathing problem when running from cron.

for example, when run from the command-line as noted:

/opt/logrotate/bin/logrotate logrotate.conf

what is your current directory, and is logrotate.conf in it?

My first step would be to put the full path to logrotate.conf in the cron job and see what happens.
Jeff_Traigle
Honored Contributor

Re: Logrotate Problem in cron daemon

We use a wrapper script that we run from cron that sets the PATH so gzip can be found by logrotate.

#!/usr/bin/sh

PATH=/bin:/usr/bin:/usr/contrib/bin

/opt/logrotate/bin/logrotate /etc/logrotate.conf
--
Jeff Traigle
Arturo Galbiati
Esteemed Contributor

Re: Logrotate Problem in cron daemon

Hi,
create a new script to add in crontab under teh user you run successfully online and add

. .profile
opt/logrotate/bin/logrotate logrotate.conf

to be sure that all neeede paths will be loaded.

HTH,
Art
Muhib Tanim
Occasional Visitor

Re: Logrotate Problem in cron daemon

Thanks Jeff Traigle

PATH=/bin:/usr/bin:/usr/contrib/bin

solved the problem
Muhib Tanim
Occasional Visitor

Re: Logrotate Problem in cron daemon

solved