Answer the question
In order to leave comments, you need to log in
How to understand why logrotate didn't work by itself? Do I need to restart cron service in Ubuntu?
In order for logrotate to run every hour, I moved its script from the daily cron folder to hourly - but the nginx log is still swollen to several gigs (there is a rotation config). I manually launched in the console logrotate /etc/logrotate.conf
and only then did the rotation take place. Ubuntu 20.04
How to understand why logrotate didn't work by itself?
#!/bin/sh
# skip in favour of systemd timer
if [ -d /run/systemd/system ]; then
exit 0
fi
# this cronjob persists removals (but not purges)
if [ ! -x /usr/sbin/logrotate ]; then
exit 0
fi
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit $EXITVALUE
Answer the question
In order to leave comments, you need to log in
# skip in favour of systemd timer
if [ -d /run/systemd/system ]; then
exit 0
fi
# systemctl status logrotate.timer
● logrotate.timer - Daily rotation of log files
Loaded: loaded (/lib/systemd/system/logrotate.timer; enabled; vendor preset: enabled)
Active: active (waiting) since Sat 2020-10-17 03:30:01 MSK; 2 months 24 days ago
Trigger: Mon 2021-01-11 00:00:00 MSK; 17h left
Triggers: ● logrotate.service
Docs: man:logrotate(8)
man:logrotate.conf(5)
# cat /lib/systemd/system/logrotate.timer
[Unit]
Description=Daily rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
[Timer]
OnCalendar=daily
AccuracySec=12h
Persistent=true
[Install]
WantedBy=timers.target
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question