Linux logs not rotating

logrotate not rotating the logs

/var/log/mysql/mysql-slow.log < daily rotate 3 compress notifempty missingok create 660 mysql adm postrotate if test -x /usr/bin/mysqladmin && \ /usr/bin/mysqladmin ping &>/dev/null then /usr/bin/mysqladmin flush-logs fi endscript 
  1. I verified that the log is indeed in /var/log/mysql/mysql-slow.log
  2. mysqladmin lines work fine when run as root
  3. mysql is able to write to the mysql-slow.log
$ logrotate -d -f mysql-slow reading config file mysql-slow reading config info for /var/log/mysql/mysql-slow.log Handling 1 logs rotating pattern: /var/log/mysql/mysql-slow.log forced from command line (3 rotations) empty log files are not rotated, old logs are removed considering log /var/log/mysql/mysql-slow.log log needs rotating rotating log /var/log/mysql/mysql-slow.log, log->rotateCount is 3 dateext suffix '-20120329' glob pattern '-55249594' renaming /var/log/mysql/mysql-slow.log.3.gz to /var/log/mysql/mysql-slow.log.4.gz (rotatecount 3, logstart 1, i 3), renaming /var/log/mysql/mysql-slow.log.2.gz to /var/log/mysql/mysql-slow.log.3.gz (rotatecount 3, logstart 1, i 2), renaming /var/log/mysql/mysql-slow.log.1.gz to /var/log/mysql/mysql-slow.log.2.gz (rotatecount 3, logstart 1, i 1), renaming /var/log/mysql/mysql-slow.log.0.gz to /var/log/mysql/mysql-slow.log.1.gz (rotatecount 3, logstart 1, i 0), renaming /var/log/mysql/mysql-slow.log to /var/log/mysql/mysql-slow.log.1 creating new /var/log/mysql/mysql-slow.log mode = 0660 uid = 20004 gid = 4 running postrotate script running script (multiple) with arg /var/log/mysql/mysql-slow.log : " if test -x /usr/bin/mysqladmin && \ /usr/bin/mysqladmin &>/dev/null then /usr/bin/mysqladmin flush-logs fi " compressing log with: /bin/gzip removing old log /var/log/mysql/mysql-slow.log.4.gz 
  1. Where is the log that shows that logrotate was successful? I want to see if there is anything that would say that there was a problem.
  2. Any ideas on why the logrotate is not working?

Источник

Why is logrotate not automatically rotated?

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) :

/var/log/cron /var/log/maillog /var/log/messages /var/log/secure /var/log/spooler < missingok sharedscripts postrotate /bin/kill -HUP `cat /var/run/syslogd.pid 2>/dev/null` 2> /dev/null || true endscript > 
#!/bin/sh /usr/sbin/logrotate -s /var/lib/logrotate/logrotate.status /etc/logrotate.conf EXITVALUE=$? if [ $EXITVALUE != 0 ]; then /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]" fi exit 0 
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=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 sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed 

UPDATE

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

Читайте также:  Create root password linux

Источник

/var/log/syslog not getting rotated

I have a fresh install of ubuntu 20.04. I have set daily rotation in /etc/logrotate.d/rsyslog file with a maxsize of 1M but the /var/log/syslog and kern.log file keeps increasing. Here is the rsyslog and /etc/logrotate.conf configuration. rsyslog file

/var/log/syslog < rotate 4 maxsize 1M daily missingok notifempty compress delaycompress # create 640 root adm postrotate /usr/lib/rsyslog/rsyslog-rotate # reload rsyslog >/dev/null 2>&1 || true endscript > /var/log/mail.info /var/log/mail.warn /var/log/mail.err /var/log/mail.log /var/log/daemon.log /var/log/kern.log /var/log/auth.log /var/log/user.log /var/log/lpr.log /var/log/cron.log /var/log/debug /var/log/messages < rotate 4 daily missingok notifempty compress delaycompress sharedscripts postrotate /usr/lib/rsyslog/rsyslog-rotate endscript >
rotate log files weekly #weekly daily # use the adm group by default, since this is the owning group # of /var/log/syslog. su root adm # su root syslog # size 3M # keep 4 weeks worth of backlogs rotate 4 # create new (empty) log files after rotating old ones create # use date as a suffix of the rotated file #dateext # uncomment this if you want your log files compressed #compress # compress # packages drop log rotation information into this directory include /etc/logrotate.d # system-specific logs may be also be configured here. #/var/log/syslog < # size 1M # rotate 4 # daily # missingok # notifempty # delaycompress # compress # postrotate # invoke-rc.d rsyslog reload >/dev/null # endscript #> 
$ logrotate --debug /etc/logrotate.conf WARNING: logrotate in debug mode does nothing except printing debug messages! Consider using verbose mode (-v) instead if this is not what you want. reading config file /etc/logrotate.conf including /etc/logrotate.d reading config file alternatives reading config file apport reading config file apt reading config file bootlog reading config file btmp reading config file cups-daemon reading config file dpkg reading config file ppp reading config file rsyslog reading config file speech-dispatcher reading config file ubuntu-advantage-tools reading config file ufw reading config file unattended-upgrades reading config file wtmp Reading state from file: /var/lib/logrotate/status Allocating hash table for state file, size 64 entries Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Creating new state Handling 17 logs rotating pattern: /var/log/alternatives.log monthly (12 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/apport.log after 1 days (7 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/apt/term.log monthly (12 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/apt/history.log monthly (12 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/boot.log after 1 days (7 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/btmp monthly (1 rotations) empty log files are rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/cups/*log after 1 days (7 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/dpkg.log monthly (12 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/ppp-connect-errors weekly (4 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/syslog weekly (4 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/mail.info /var/log/mail.warn /var/log/mail.err /var/log/mail.log /var/log/daemon.log /var/log/kern.log /var/log/auth.log /var/log/user.log /var/log/lpr.log /var/log/cron.log /var/log/debug /var/log/messages weekly (4 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/speech-dispatcher/speech-dispatcher.log /var/log/speech-dispatcher/speech-dispatcher-protocol.log after 1 days (7 rotations) empty log files are rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/speech-dispatcher/debug-epos-generic /var/log/speech-dispatcher/debug-festival /var/log/speech-dispatcher/debug-flite after 1 days (2 rotations) empty log files are rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/ubuntu-advantage.log monthly (6 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/ufw.log weekly (4 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/unattended-upgrades/unattended-upgrades.log /var/log/unattended-upgrades/unattended-upgrades-dpkg.log /var/log/unattended-upgrades/unattended-upgrades-shutdown.log monthly (6 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted rotating pattern: /var/log/wtmp monthly (1 rotations) empty log files are rotated, only log files >= 1048576 bytes are rotated, old logs are removed switching euid to 0 and egid to 4 error: error switching euid to 0 and egid to 4: Operation not permitted 

Источник

Оцените статью
Adblock
detector