Re: [webmin-l] Rotating fetchmail log

Chris <[email protected]>
Newsgroups gmane.comp.web.webmin.general
Message-ID <[email protected]>
On Tue, 2016-12-27 at 09:49 -0800, Jamie Cameron wrote:
> On 27/Dec/2016 06:42 Chris <[email protected]> wrote ..
> > 
> > On Tue, 2016-12-27 at 08:08 -0600, Chris wrote:
> > > 
> > > On Tue, 2016-12-27 at 06:28 +0300, Andrey Repin wrote:
> > > > 
> > > > 
> > > > Greetings, Chris!
> > > > 
> > > > > 
> > > > > 
> > > > > 
> > > > > On Tue, 2016-12-27 at 03:09 +0300, Andrey Repin wrote:
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > Greetings, Chris!
> > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > On Mon, 2016-12-26 at 14:18 -0800, Jamie Cameron wrote:
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > Try logging in as root via SSH and running :
> > > > > > > > 
> > > > > > > > logrotate -f /etc/logrotate.conf
> > > > > > > > 
> > > > > > > Thank you for that. I think I'm getting closer. I now
> > > > > > > have a
> > > > > > > fetchmail.logrotate file in /etc/logrotate.d which reads
> > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > /home/chris/fetchmaillog {
> > > > > > >     weekly
> > > > > > >     rotate 8
> > > > > > >     compress
> > > > > > >     datext
> > > > > > >     missingok
> > > > > > >     notifempty
> > > > > > >     create 0664 chris chris
> > > > > > >     sharedscripts
> > > > > > >     postrotate
> > > > > > >         /usr/local/bin/fetchmail --quit; fetchmail -v --
> > > > > > > nokeep
> > > > > > > --
> > > > > > > nosyslog --logfile /home/chris/fetchmaillog --uidl -m
> > > > > > > procmail
> > > > > > >         fi;
> > > > > > >     endscript
> > > > > > > }
> > > > > > 
> > > > > > ...
> > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > I'm not sure though if the postrotate command will work
> > > > > > > correctly
> > > > > > > since
> > > > > > > the commands below it are not a true script.
> > > > > > 
> > > > > > What makes you saying that?
> > > > > > 
> > > > > I'm just assuming that since from what I understand in
> > > > > reading
> > > > > the
> > > > > logrotate man page that prerotate and postrotate use a
> > > > > script.
> > > > 
> > > > 
> > > > pre/postrotate ... endscript blocks DEFINE a script, that will
> > > > be
> > > > run
> > > > upon
> > > > appropriate event. Not "use".
> > > > 
> > > Thanks Andrey, I understand now. Hoping that it will work the way
> > > I
> > > have it setup at least running logrotate -d doesn't give me any
> > > errors.
> > > Logrotate runs each morning at 7:30. Checking I see
> > > 
> > > 1629780 Dec 27 07:42 fetchmaillog-20161227
> > > 
> > > however a couple of issues. 1)the log wasn't compressed and
> > > 2)fetchmail
> > > wasn't stopped although the new fetchmaillog was created it
> > > wasn't
> > > being written to. The way the fetchmail.logrotate file now reads
> > > in
> > > /etc/logrotate.d is
> > > 
> > > /home/chris/fetchmaillog {
> > > 	daily
> > > 	rotate 8
> > > 	compress
> > > 	datext
> > > 	missingok
> > > 	notifempty
> > > 	create 0664 chris chris
> > > 	sharedscripts
> > > 	postrotate
> > > 	/usr/local/bin/fetchmail --quit; fetchmail -v --nokeep --
> > > nosyslog --logfile /home/chris/fetchmaillog --uidl -m procmail
> > > 	endscript
> > > }
> > > 
> > > The new fetchmaillog file was created however it was staying at 0
> > > in
> > > size. Running pgrep fetchmail showed it was running so is it
> > > possible
> > > that I need a prerotate/endscript that will be written as:
> > > 
> > > prerotate
> > > /usr/local/bin/fetchmail --quit
> > > endscript
> > > 
> > > and only have the postrotate/endscript command to restart
> > > fetchmail
> > > after the log is rotated?
> > > 
> > After writing the above I saw this in my 'cronjobs' mail folder
> > 
> > /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 corrected my misspelling of 'dateext'. I'm wondering if I use the
> > 'nosharedscripts' option will that allow fetchmail to be restarted
> > as
> > user 'chris' instead of root or attempt to start as root?
> 
> If you want fetchmail to be run as a different user, I'd 
> recommend using a command like :
> 
> su chris -c "/usr/local/bin/fetchmail --quit; fetchmail -v --nokeep
> --nosyslog --logfile /home/chris/fetchmaillog --uidl -m procmail"
> 
Thanks Jamie, I'll try it only using sudo -u chris to see how it works
out.

-- 
Chris
KeyID 0xE372A7DA98E6705C
31.11972; -97.90167 (Elev. 1092 ft)
14:43:41 up 6 days, 23:49, 1 user, load average: 0.18, 0.11, 0.08
Ubuntu 16.04.1 LTS, kernel 4.4.0-57-generic #78-Ubuntu SMP Fri Dec 9
23:50:32 UTC 2016

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

-
Forwarded by the Webmin mailing list at [email protected]
To remove yourself from this list, go to
http://lists.sourceforge.net/lists/listinfo/webadmin-list
signature.asc (application/pgp-signature, 181 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEABECAAYFAlhi0wkACgkQ43Kn2pjmcFznpwCbBZcPn/TYPZro04E/HOK42t6M
c88AnRJTQOHEOAHO2e/6hfeHHkbInMTq
=XnNx
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.