From: Chris <cpo...@em...> - 2016-09-25 00:28:13
|
Is there a way that this can be done somehow? Thanks Chris -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 19:25:03 up 21:19, 1 user, load average: 0.68, 0.34, 0.22 Ubuntu 16.04.1 LTS, kernel 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 |
From: Carlos E. R. <rob...@te...> - 2016-09-25 00:53:32
Attachments:
signature.asc
|
On 2016-09-25 02:28, Chris wrote: > Is there a way that this can be done somehow? I have fetchmail log into syslog, and then handle rotation in the usual manner. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar) |
From: Chris <cpo...@em...> - 2016-09-25 01:20:04
|
On Sun, 2016-09-25 at 02:53 +0200, Carlos E. R. wrote: > On 2016-09-25 02:28, Chris wrote: > > > > Is there a way that this can be done somehow? > I have fetchmail log into syslog, and then handle rotation in the > usual > manner. > That makes sense, I hadn't thought of doing it that way, thanks. -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 20:14:01 up 22:08, 1 user, load average: 0.41, 0.25, 0.27 Ubuntu 16.04.1 LTS, kernel 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 |
From: Carlos E. R. <rob...@te...> - 2016-09-25 01:24:58
Attachments:
signature.asc
|
On 2016-09-25 03:19, Chris wrote: > On Sun, 2016-09-25 at 02:53 +0200, Carlos E. R. wrote: >> On 2016-09-25 02:28, Chris wrote: >>> >>> Is there a way that this can be done somehow? >> I have fetchmail log into syslog, and then handle rotation in the >> usual manner. >> > That makes sense, I hadn't thought of doing it that way, thanks. Welcome. It goes into the same file as "mail entries", so that I can track a single mail coming from fetchmail, into postfix, then procmail, dovecot... it is not trivial but can be done. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar) |
From: Chris <cpo...@em...> - 2016-09-25 02:08:50
|
On Sun, 2016-09-25 at 03:24 +0200, Carlos E. R. wrote: > On 2016-09-25 03:19, Chris wrote: > > > > On Sun, 2016-09-25 at 02:53 +0200, Carlos E. R. wrote: > > > > > > On 2016-09-25 02:28, Chris wrote: > > > > > > > > > > > > Is there a way that this can be done somehow? > > > I have fetchmail log into syslog, and then handle rotation in the > > > usual manner. > > > > > That makes sense, I hadn't thought of doing it that way, thanks. > Welcome. > > It goes into the same file as "mail entries", so that I can track a > single mail coming from fetchmail, into postfix, then procmail, > dovecot... it is not trivial but can be done. > I can just have procmail log to syslog also. I was attempting to use webmins logrotate setup yesterday but couldn't get it to where it would kill the fetchmail process, rotate and recreate the log then restart fetchmail. -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 21:03:01 up 22:57, 1 user, load average: 0.18, 0.32, 0.32 Ubuntu 16.04.1 LTS, kernel 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 |
From: Carlos E. R. <rob...@te...> - 2016-09-25 09:32:49
Attachments:
signature.asc
|
On 2016-09-25 04:08, Chris wrote: > On Sun, 2016-09-25 at 03:24 +0200, Carlos E. R. wrote: > I can just have procmail log to syslog also. I was attempting to use > webmins logrotate setup yesterday but couldn't get it to where it would > kill the fetchmail process, rotate and recreate the log then restart > fetchmail. If you use "logrotate" it is quite simple, actually. It is a directory "/etc/logrotate.d" with config files. Take the one for apache, it contains entries for each file it handles: var/log/apache2/access_log { compress dateext maxage 365 rotate 99 size=+4096k notifempty missingok create 644 root root postrotate /usr/bin/systemctl reload apache2.service endscript } The "postrotate" is what it does with the process. I see one file for fetchmail, too: var/log/fetchmail { compress dateext maxage 365 rotate 99 size=+1024k notifempty missingok copytruncate create 0600 fetchmail root } It doesn't kill the service. Instead it copies and trunctates the log. This is in openSUSE, other distros may vary. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar) |
From: Chris <cpo...@em...> - 2016-09-25 12:46:52
|
On Sun, 2016-09-25 at 11:32 +0200, Carlos E. R. wrote: > On 2016-09-25 04:08, Chris wrote: > > > > On Sun, 2016-09-25 at 03:24 +0200, Carlos E. R. wrote: > > > > > I can just have procmail log to syslog also. I was attempting to > > use > > webmins logrotate setup yesterday but couldn't get it to where it > > would > > kill the fetchmail process, rotate and recreate the log then > > restart > > fetchmail. > If you use "logrotate" it is quite simple, actually. It is a > directory > "/etc/logrotate.d" with config files. Take the one for apache, it > contains entries for each file it handles: > > var/log/apache2/access_log { > compress > dateext > maxage 365 > rotate 99 > size=+4096k > notifempty > missingok > create 644 root root > postrotate > /usr/bin/systemctl reload apache2.service > endscript > } > > The "postrotate" is what it does with the process. I see one file for > fetchmail, too: > > var/log/fetchmail { > compress > dateext > maxage 365 > rotate 99 > size=+1024k > notifempty > missingok > copytruncate > create 0600 fetchmail root > } > > It doesn't kill the service. Instead it copies and trunctates the > log. > > This is in openSUSE, other distros may vary. > Thanks for that Carlos, I'll put that in my /etc/logrotate.d folder and see if it works. -- Chris KeyID 0xE372A7DA98E6705C 31.11972; -97.90167 (Elev. 1092 ft) 07:45:05 up 1 day, 9:39, 1 user, load average: 1.75, 1.61, 1.03 Ubuntu 16.04.1 LTS, kernel 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016 |
From: Chris <cpo...@em...> - 2016-12-27 21:39:04
Attachments:
signature.asc
|
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 |