From: Chris <cpo...@em...> - 2016-12-27 21:39:04
|
On Sat, 2016-09-24 at 19:28 -0500, Chris wrote: > Is there a way that this can be done somehow? > > Thanks > Chris > I started this thread in Sept and I'm just now digging into this again. Some things I've done and also some I've found I need but not sure how to accomplish. I've got a 'fetchmail.logrotate' file in /etc/logrotate.d: /home/chris/fetchmaillog { prerotate /usr/local/bin/fetchmail --quit endscript daily rotate 8 compress dateext missingok notifempty create 0664 chris chris postrotate /usr/local/bin/fetchmail -v --nokeep --nosyslog --logfile /home/chris/fetchmaillog --uidl -m procmail endscript } Running sudo logrotate -vd /etc/logrotate.conf shows me it reads the fetchmail.logrotate file rotating pattern: /home/chris/fetchmaillog after 1 days (8 rotations) empty log files are not rotated, old logs are removed switching euid to 0 and egid to 104 considering log /home/chris/fetchmaillog log does not need rotating switching euid to 0 and egid to 0 When the daily cron job for logrotate was run this morning I got this output mailed to me: /etc/cron.daily/logrotate: error: fetchmail.logrotate:43 unknown option 'datext' -- ignoring line fetchmail: WARNING: Running as root is discouraged. fetchmail: no other fetchmail is running fetchmail: WARNING: Running as root is discouraged. fetchmail: no mailservers have been specified. error: error running shared postrotate script for '/home/chris/fetchmaillog ' run-parts: /etc/cron.daily/logrotate exited with return code 1 I've corrected the misspelling of 'dateext' however as can be seen it tried to restart fetchmail as root. I've discovered that what I need is a different state file for user chris -s, --state <statefile> Tells logrotate to use an alternate state file. This is useful if logrotate is being run as a different user for various sets of log files. The default state file is /var/lib/logrotate.status. I imagine I need something like this which is in the /etc/cron.daily folder #!/bin/sh # Clean non existent log file entries from status file cd /var/lib/logrotate test -e status || touch status head -1 status > status.clean sed 's/"//g' status | while read logfile date do [ -e "$logfile" ] && echo "\"$logfile\" $date" done >> status.clean mv status.clean status test -x /usr/sbin/logrotate || exit 0 /usr/sbin/logrotate /etc/logrotate.conf So, can I modify the above and call it something else while changing the first line to read something like cd /home/chris/.logrotate and the last line to be something like sudo -u chris /usr/sbin/logrotate /home/chris/.logrotate.conf and put this /home/chris/fetchmaillog { prerotate /usr/local/bin/fetchmail --quit endscript daily rotate 8 compress dateext missingok notifempty create 0664 chris chris postrotate /usr/local/bin/fetchmail -v --nokeep --nosyslog --logfile /home/chris/fetchmaillog --uidl -m procmail endscript } into the /home/chris/.logrotate.conf file? Apologies for the lengthy post but I think I've covered everything I've done so far and the results or lack there of. Chris -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 14:57:23 up 7 days, 3 min, 1 user, load average: 0.15, 0.21, 0.14 Ubuntu 16.04.1 LTS, kernel 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9 23:50:32 UTC 2016 |