I've set you up to rotate daily, but you don't.

But when I do it manually, it does work.

logrotate -vf /etc/logrotate.conf

This is my log file to rotate. /mylogs/log (-rwxrwxrwxrwx 1 admin admin)

This is the system configuration.

/etc/logrotate.conf (-rw-r--r-- 1 root root):

/mylogs/log {
create 0640 root utmp
rotate 10

/etc/logrotate.d/syslog (-rw-r--r-- 1 root root):

/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || 

/etc/cron.daily/logrotate (-rwx------ 1 root root):


/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with 
exit 0

/etc/crontab (-rw-r--r--. 1 root root):


# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR 
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

Additional information. CentOS operating system

How can I get it to rotate properly.


I think the problem is in assigning owner, group and permissions of 3 things. The /mylogs/ folder (root root) The /mylogs/log file (admin admin)
The create option of logrotate.conf (create 0640 root utmp)

Someone with logrotate running correctly. Please let me know how you have assigned the previous 3 values. the folder - the file - the create config in logrotate.conf

  • Can you provide information how do you "run manually"? At the moment I can see you have different file ownership in different places. Nov 26, 2017 at 13:41
  • Hi, thanks for the comment, I added the line that I run manually.
    – xav
    Nov 26, 2017 at 13:53
  • Did you look at your logfiles, you should see some cron activity telling you it executes logrotate each day. Nov 26, 2017 at 14:44
  • Sorry but I don't know how to check what you tell me, I'll see if I can get the information to do it.
    – xav
    Nov 26, 2017 at 15:13

2 Answers 2


Join two strings here

/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status 

To one string like this one:

/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf

Or put backslash after first string, like this:

/usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status \

p.s. there is an excellent option -x for /bin/sh to make debug output from shell, and I guess you'll be able to find this mistype next time if you'd try to run /bin/sh -x /etc/cron.daily/logrotate

  • In the configuration file is written correctly, I have pasted it wrong in the post, now I correct it. Thank you very much
    – xav
    Nov 26, 2017 at 15:12
  • ok. @xav So next guess: is there /var/lib/logrotate/logrotate.status file and folder for it: /var/lib/logrotate/ ? Logrotate may skip rotating logs if there is no such folder. And also there may be some notes about errors on state file. Please check it for any warnings. Nov 26, 2017 at 15:15
  • Hello, the folder and file exist. There are no warnings or error messages inside. /var/lib/logrotate/logrotate.status (-rw-rw-r-- 1 admin admin)
    – xav
    Nov 26, 2017 at 15:44
  • @xav are there any records about your /mylogs files in status file? You have -s /var/lib/logrotate/status on your cron file and by hands you run without it, this also may affect the way file is rotated. You also could use -d flag for logrotate to show what it will do without actual rotating and compare -d outputs for -s /var/lib/logrotate/status and without -s runs. Nov 26, 2017 at 16:07
  • Hi this is using: -d link And this without d or s :error: error creating output file /mylogs/log-20171126: permission denied
    – xav
    Nov 26, 2017 at 17:53

after several tests I managed to get it to rotate correctly again.

To do this, I have assigned the user (root) and group (root) of the log file.

Also change your permissions to 666.

With respect to the folder containing the file, it is assigned a user (root) of group (root) and 755 permissions.

Finally within the configuration of logrotate.conf the configuration assigned to this property 'create' was user (root), group (utmp) and permissions (644)

I hope this information will be useful in case someone has a similar problem.

Greetings and thank you.

  • 2
    You should not have permissions 666, instead you should use 644. With the 'w' flag as "other" (the 006 represents ------rw-) which means anyone on that computer can temper with your file. Jul 30, 2018 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .