Daily emails from Cron to Root

Posted December 10, 2014 3.4k views

I recently Installed postfix (and I redirected all emails to Gmail)
every day I receive an email from Cron to root@mydomain, that contains this message:

initctl: invalid command: reopen-logs
Try `initctl –help’ for more information.
invoke-rc.d: initscript php5-fpm, action “reopen-logs” failed.
error: error running non-shared postrotate script for /var/log/php5-fpm.log of ’/var/log/php5-fpm.log ’
run-parts: /etc/cron.daily/logrotate exited with return code 1

the things that I have done recently:

  • my Host name was not a fully qualified domain name so I changed it in Ubuntu hostname file to a domain (probably unrelated :) )
  • I read somewhere to change cron mailto to “ ” will solve the problem. is it true?


1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

It looks like this is a known bug in the php5 package: Bug #1230917 “php5-fpm logrotate errors after package switched t…” : Bugs : php5 package : Ubuntu.

You can manually fix it so that you don’t have to wait for a package update to be pushed.

Edit /etc/logrotate.d/php5-fpm and replace

        invoke-rc.d php5-fpm reopen-logs > /dev/null



Then, create a file in /usr/lib/php5 called php5-fpm-reopenlogs:

sudo mkdir -p /usr/lib/php5
sudo touch /usr/lib/php5/php5-fpm-reopenlogs
sudo chmod +x /usr/lib/php5/php5-fpm-reopenlogs

with the following content:

[ -r /etc/default/php5-fpm ] && . /etc/default/php5-fpm
CONF_PIDFILE=$(sed -n 's/^[[:space:]]*pid[[:space:]]*=[[:space:]]*//p' $CONFFILE)
[ -r "$PIDFILE" ] && kill -USR1 $(cat "$PIDFILE") > /dev/null
exit 0

Hi. strangely I didn’t receive an email for your response to my question. anyway… I’m grateful for your help