Score:0

How to properly configure a custom logrotate configuration file?

vn flag

For the first time today, I am trying to write a configuration file for logrotate. When I restart the logrotate service, I get the following error: logrotate.service: Failed with result 'exit-code'.

If I delete my file and restart logrotate.service, everything is OK

Here is my logrotate.conf configuration file

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# use date as a suffix of the rotated file
#dateext

# uncomment this if you want your log files compressed
#compress

# packages drop log rotation information into this directory
include /etc/logrotate.d

# system-specific logs may be also be configured here.

Here is my custom configuration file

/var/www/webd/logs/clean.log
{
        rotate 12
        monthly
        missingok
        notifempty
        compress
}

What is wrong with this file?

Thanks,

Thierry

Tilman Schmidt avatar
bd flag
What is your operating system and version? Is logrotate actually configured to run as a service on that system? What does `sudo systemctl status logrotate` (or equivalent on your OS) report? Please edit your question to add that information.
Score:0
vn flag

Thanks to your answer @Tilman Schmidt, I realized that my problem came from a problem of access right to the log file

févr. 24 08:34:30 logrotate[23728]: error: skipping "/var/www/webd/logs/clean.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

by adding the clause su webd webd in my configuration file and by restarting the logrotate service, everything is back to normal

/var/www/webd/logs/clean.log
{
        rotate 12
        monthly
        missingok
        notifempty
        compress
        su webd webd
}

Thanks for your help :)

theirman

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.