V
V
Vadim Timoshenko2019-01-13 20:30:53
linux
Vadim Timoshenko, 2019-01-13 20:30:53

Why doesn't logrotate run by cron?

There is a config for nginx log rotation:

/var/log/nginx/*.log {
    size=100K
  daily
  missingok
  rotate 14
  compress
  delaycompress
  notifempty
  create 0640 www-data adm
  sharedscripts
  prerotate
    if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
      run-parts /etc/logrotate.d/httpd-prerotate; \
    fi \
  endscript
  postrotate
    invoke-rc.d nginx rotate >/dev/null 2>&1
  endscript
}

I use logrotate -f /etc/logrotate.d/nginx and everything works successfully.
But automatically, every minute, cron does not work.
In crontab -e wrote like this:
* * * * * /usr/sbin/logrotate /etc/logrotate.d/nginx

Where did you go wrong? service cron restart did.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadim Timoshenko, 2019-01-13
@PbI6A_KuT

Found an error. Didn't add the -f option .

* * * * * /usr/sbin/logrotate -f /etc/logrotate.d/nginx

P
pfemidi, 2019-01-13
@pfemidi

Maybe in crontab it is necessary to write down with a repetition interval?

*/1 * * * * root  /usr/sbin/logrotate /etc/logrotate.d/nginx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question