Logrotate doesn't rotate sync gateway logs

I am running my sync gateway on CentOS 7.2

I have setup the logrotate configuration under /etc/logrotate.d/

/home/sync_gateway/logs/*.log {
su sync_gateway sync_gateway
rotate 2
size 10M
/usr/bin/pkill -HUP sync_gateway > /dev/null

Also i modified the sync_gateway.service file under /usr/lib/systemd/system/ to have the sync gateway startup with the logFilePath option

ExecStart=/usr/bin/bash -c ‘${GATEWAY} -logFilePath=${LOGS}/${NAME}_error.log ${CONFIG}’

However, the log files are not rotated daily. I tried with logrotate -d option to see any potential issues and everything looks good,also when i manually invoke logrotate against the sync gateway configuration it works, just that it doesn’t rotate daily using the cron job. I verified also that the cron job status shows logrotate has ‘finished’ running.

Has anyone else faced a similar issue?


I added the same logrotate config as you as manually running it successfully rotated the logs.

I’m not sure why cron is not running logrotate, there could be many reasons, but you might try the following:

###Short version:

Get crond to relaod the 0hourly cron.d config.

$ touch /etc/cron.d/0hourly
$ kill -HUP <crondPID>
$ cat /var/log/cron

You should see a message similar to:

`localhost crond[PID] (system) RELOAD (/etc/cron.d/0hourly)

This should run anacron hourly which will run logrotate daily.

###Long Version:

CentOS 7 added anacron in addition to cron.

This leads to a chain of dependencies in order for logrotate to be scheduled for daily running.


This should be picked up by crond automatically and should run the following command every hour

run-parts /etc/cron.hourly


This script will run check every hour if anacron has been run today, if not it will be run. Anacron will load its configuration from:


It will run all the scripts in /etc/cron.daily once a day

/etc/cron.daily/logrotate will be run once a day

Logrotate will load its config from:


Which includes all logrotate scripts from:


Which should contain your sync_gateway logrotate script.

Check that all the above files are in place, if they are you can run the commands above in the short version to make sure the cron.d 0hourly config is being loaded as this is the root dependency.

Thanks Andy for the detailed response. I did test and verified that the hourly script was being picked up and also written into the /var/log/cron file. However the log file for some reason isn’t still getting rotates.