LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-01-2017, 10:17 AM   #1
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 18.04 LTS
Posts: 287

Rep: Reputation: 20
Fetchmail won't restart after log rotation


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.
 
Old 01-01-2017, 06:06 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 15,900
Blog Entries: 27

Rep: Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675Reputation: 4675
Quote:
fetchmail: can't accept options while a background fetchmail is running.
No answers, but two questions: Why would you need to stop fetchmail to run logrotate, and have you checked that fetchmail is actually stopping?

I ask the latter only because of the line quoted above.
 
Old 01-01-2017, 06:44 PM   #3
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 18.04 LTS
Posts: 287

Original Poster
Rep: Reputation: 20
Answering the first, I really don't know, I'm just 'assuming' that it needs to be stopped to rotate the log. I can remove the prerotate script and try it. On the 2nd, yes, I'm sure it's stopped because I had to manually restart it this morning. I'll remove the pre and post rotate scripts and see what happens. If it's not stopped it doesn't need to be restarted. Will let you know.
 
Old 01-01-2017, 09:29 PM   #4
Toadman
Member
 
Registered: Aug 2002
Location: Copperas Cove, Texas
Distribution: Ubuntu 18.04 LTS
Posts: 287

Original Poster
Rep: Reputation: 20
I changed the fetchmail.logrotate file to read

Code:
/home/chris/fetchmaillog {
	hourly
	rotate 8
	compress
	dateext
	missingok
	notifempty
	create 0664 chris chris
        sharedscripts
        postrotate
        /usr/local/bin/fetchmail --quit
        /usr/local/bin/fetchmail -v --nokeep --nosyslog --logfile /home/chris/fetchmaillog --uidl -m procmail
        endscript
}
and it now appears to work

Code:
reading config file /home/chris/logrotate/fetchmail.logrotate

Handling 1 logs

rotating pattern: /home/chris/fetchmaillog  forced from command line (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 '-2017010120'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
glob finding old rotated logs failed
renaming /home/chris/fetchmaillog to /home/chris/fetchmaillog-2017010120
creating new /home/chris/fetchmaillog mode = 0664 uid = 1000 gid = 1000
running postrotate script
fetchmail: background fetchmail at 9946 killed.
compressing log with: /bin/gzip
The way it is now I see it rotating and renaming the log, creating the new log then fetchmail is killed and restarted which allows writing to the new log

Code:
chris@localhost:~$ ls -l fetchmaillog*
-rw-rw-r-- 1 chris chris 15596 Jan  1 20:20 fetchmaillog
chris@localhost:~$ ls -l fetchmaillog*
-rw-rw-r-- 1 chris chris 10174 Jan  1 20:22 fetchmaillog
-rw-rw-r-- 1 chris chris  2535 Jan  1 20:20 fetchmaillog-2017010120.gz
So, I can go back to the weekly setting. I knew it had to be something stupid I was doing. Took me long enough to figure it out.
 
  


Reply

Tags
fetchmail, logrotate


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Default rotation of logins log (/var/log/wmtp) gacanepa Linux - Newbie 2 10-01-2013 07:59 PM
Log parsing but issue with log rotation Rohant Linux - Server 1 05-30-2013 10:09 PM
How to change Debian log rotation of syslog and daemon.log onmountain Linux - Newbie 2 07-31-2008 03:27 AM
Log Rotation for snort log does not seem to be working CentOS4.5 JasonKretzer Linux - Security 3 06-25-2007 01:25 PM
Red Hat won't Shutdown / restart or Log Off JoshSmith41 Linux - Distributions 1 07-28-2003 07:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration