Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logrotate Error #1507

Closed
mindrunner opened this issue May 10, 2020 · 11 comments · Fixed by #1514
Closed

Logrotate Error #1507

mindrunner opened this issue May 10, 2020 · 11 comments · Fixed by #1514
Assignees

Comments

@mindrunner
Copy link
Contributor

Got this today:

/etc/cron.daily/logrotate:
logrotate_script: 6: logrotate_script: Syntax error: "fi" unexpected
error: error running non-shared postrotate script for /var/log/mail/freshclam.log of '/var/log/mail/freshclam.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1
@youtous
Copy link
Contributor

youtous commented May 10, 2020

What is the content of your /etc/cron.daily/logrotate?

Is there any error when running manually /usr/sbin/logrotate /etc/logrotate.conf?

@mindrunner
Copy link
Contributor Author

#!/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
root@mx0:/# /usr/sbin/logrotate /etc/logrotate.conf
root@mx0:/# 

Seems all good here. Normally it is working fine. Just last night it seemed to fail.

@erik-wramner
Copy link
Contributor

I think my fix was less than stellar, but the error only occurs when the freshclam logs have been rotated. I commented out the postrotate action, but only a comment inside an if statement is apparently not correct. This can be ignored (the file has already been rotated) but it should of course be fixed.

@erik-wramner erik-wramner self-assigned this May 11, 2020
@mindrunner
Copy link
Contributor Author

happened again today

image

@gmasse
Copy link
Contributor

gmasse commented May 17, 2020

I think the issue is in /etc/logrotate.d/clamav-freshclam

/var/log/mail/freshclam.log {
     rotate 12
     weekly
     compress
     delaycompress
     missingok
     create 640  clamav adm
     postrotate
     if [ -d /run/systemd/system ]; then
         systemctl -q is-active clamav-freshclam && systemctl kill --signal=SIGHUP clamav-freshclam || true
     else
         #invoke-rc.d clamav-freshclam reload-log > /dev/null || true
     fi
     endscript
     }

If I compare with clamav-daemon, if suppose the commented line would be replaced by:

         /usr/bin/supervisorctl signal hup clamav-freshclam >/dev/null || true

AFAIK freshclam is not run as daemon. Supervisorctl will fail silently. Not sure if it is a problem...

@mindrunner
Copy link
Contributor Author

Alright. Is the directory /run/systemd/system supposed to be there?

We should eliminate the whole else block. It doesn't do anything, right?

@erik-wramner
Copy link
Contributor

Freshclam runs from cron, not as a daemon. The whole postrotate block (from postrotate to endscript?) should be removed, it is not needed.

@mindrunner
Copy link
Contributor Author

@gmasse You were faster than me! Thanks for fixing! :)

erik-wramner added a commit that referenced this issue May 19, 2020
Fix #1507 - Do not try to reload freshclam daemon after log rotation
@helmutundarnold
Copy link
Contributor

helmutundarnold commented May 28, 2020 via email

@erik-wramner
Copy link
Contributor

@helmutundarnold this has been fixed in latest and in 7.0.1. Perhaps you didn't recreate the container (compose down/up) or something? This is the logrotate job I have:

/var/log/mail/freshclam.log {
     rotate 12
     weekly
     compress
     delaycompress
     missingok
     create 640  clamav adm
     }

As you can see there is no commented invoke-rc.d left.

@helmutundarnold
Copy link
Contributor

helmutundarnold commented May 29, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants