I've been wracking my brain on this for over a week now figuring how can something so simple be so hard. I've tried both the sharedscripts and nosharedscripts in my ~/logrotate/fetchmail.logrotate file and I can get fetchmail to quit before rotation, the new log is created but fetchmail will not restart. Here's my fetchmail.logrotate config file:
Code:
/home/chris/fetchmaillog {
weekly
rotate 8
compress
dateext
missingok
notifempty
create 0664 chris chris
nosharedscripts
prerotate
/usr/local/bin/fetchmail --quit
endscript
postrotate
/usr/local/bin/fetchmail -v --nokeep --nosyslog --logfile /home/chris/fetchmaillog --uidl -m procmail
endscript
}
The output mailed to me of the cronjob is:
Code:
reading config file /home/chris/logrotate/fetchmail.logrotate
Handling 1 logs
rotating pattern: /home/chris/fetchmaillog weekly (8 rotations)
empty log files are not rotated, old logs are removed
considering log /home/chris/fetchmaillog
log needs rotating
rotating log /home/chris/fetchmaillog, log->rotateCount is 8
dateext suffix '-20170101'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
running prerotate script
fetchmail: background fetchmail at 1509 killed.
renaming /home/chris/fetchmaillog to /home/chris/fetchmaillog-20170101
creating new /home/chris/fetchmaillog mode = 0664 uid = 1000 gid = 1000
running postrotate script
fetchmail: can't accept options while a background fetchmail is running.
argc = 9, arg list:
arg 1 = "-v"
arg 2 = "--nokeep"
arg 3 = "--nosyslog"
arg 4 = "--logfile"
arg 5 = "/home/chris/fetchmaillog"
arg 6 = "--uidl"
arg 7 = "-m"
arg 8 = "procmail"
error: error running non-shared postrotate script for /home/chris/fetchmaillog of '/home/chris/fetchmaillog '
The command I'm using is
Code:
/usr/sbin/logrotate -v --state=/home/chris/logrotate/status /home/chris/logrotate/fetchmail.logrotate
The old file was renamed as it should be
chris chris 7012598 Jan 1 00:00 fetchmaillog-20170101
and as I haven't added in the 'nodelaycompress' option won't be compressed until the next run.
Bottom line, everything seems to be working correctly fetchmail however for some reason won't restart.
System is Ubuntu 16.04.1 LTS
fetchmail release 6.4.0.beta2+SSL-SSLv2-SSLv3+NLS
logrotate: Installed: 3.8.7-2ubuntu2
Thanks for any advice on what I'm doing wrong.