1

I'm trying to rotate my application's log daily, but for some unknown reason, it's not working. If I debug its logrotate definition, it says that it won't rotate it. However, only when I force its rotation it works..

What am I missing here?

logrotate definition (/etc/logrotate.d/application)

/tmp/company.0000/application.log {
  daily
  rotate 7
  compress
  copytruncate
  missingok
  extension .log
  dateext
  dateformat _%Y%m%d
  su root valter
  create 440 valter valter
}

list everything in the folder

valter@eniac:~$ ls -ltha /tmp/company.0000/
total 2,8M
drwxrwxrwx 9 root   root    96K Aug 30 17:25 ..
drwxrwxr-x 2 valter valter 4,0K Aug 30 17:25 .
-rw-rw-r-- 1 valter valter 2,7M Aug 30 17:00 application.log

modified the file date

valter@eniac:~$ sudo touch -m --date="2016-08-01" /tmp/company.0000/application.log
valter@eniac:~$ ls -ltha /tmp/company.0000/
total 2,8M
drwxrwxrwx 9 root   root    96K Aug 30 17:25 ..
drwxrwxr-x 2 valter valter 4,0K Aug 30 17:25 .
-rw-rw-r-- 1 valter valter 2,7M Aug  1 00:00 application.log

debug logrotate without modified the log itself

valter@eniac:~$ sudo logrotate -d /etc/logrotate.d/application 
reading config file /etc/logrotate.d/application
extension is now .log

Handling 1 logs

rotating pattern: /tmp/company.0000/application.log  after 1 days (7 rotations)
empty log files are rotated, old logs are removed
switching euid to 0 and egid to 1000
considering log /tmp/company.0000/application.log
  log does not need rotating
switching euid to 0 and egid to 0

forcing log to rotate and listing

valter@eniac:~$ sudo logrotate --force /etc/logrotate.d/application 
valter@eniac:~$ ls -ltha /tmp/company.0000/
total 264K
drwxrwxr-x 2 valter valter 4,0K Aug 30 17:26 .
-rw-rw-r-- 1 valter valter    0 Aug 30 17:26 application.log
drwxrwxrwx 9 root   root    96K Aug 30 17:25 ..
-rw-rw-r-- 1 valter valter 158K Aug  1 00:00 application_20160830.log.gz
  • Do you have a global size option? – Mark Plotnick Aug 30 '16 at 16:12
  • No @MarkPlotnick, is that necessary ? I thought that wouldn't be necessary once I'm saying to rotate daily only. – Valter Silva Aug 30 '16 at 16:34
  • It's not required to have a size option, but if you do have one, it'll take precedence over daily. – Mark Plotnick Aug 30 '16 at 17:00
  • What are the permissions on /etc/logrotate.d/application ? It should be similar to 644; specifically it should not have any x flags set; that can cause logrotate to skip the file in some versions. – Stephen Harris Aug 30 '16 at 17:15
  • My permissions are 644. – Valter Silva Aug 31 '16 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.