Hi, I’m receving emails from remote server with this message. I’m not sure about its meaning (I am not familiar with cron and logrotate). Is it significant? How can I fix it? Thanks!
/etc/cron.daily/logrotate:
error: error running shared postrotate script for '/var/log/nginx/*.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1
@aitor could you confirm that the version of Trellis you are working with includes the postrotate script update from roots/trellis#377 and that it appears in your server as well, e.g.,
What version of Nginx are those of you getting the error using? There are some known bugs affecting some Nginx versions. Also, are the permissions for your logs folder/logs set correctly?
Permissions look fine, you can manually fix the one log file (x.log.4.gz) if you need to - it’s an artifact of how nginx is running with roots/trellis. You can avoid it altogether in future installs by adding a script to be run manually or by ansible after the deploy.
One common reason for the error you’re seeing is that Upstart sucks. Quick check-- are both the Upstart and systemV initialization configs present (/etc/init/nginx and /etc/init.d/nginx)? You’re running on Ubuntu 14.04 (Trusty) right?
If they’re both there, stop ngninx, delete the Upstart one and restart. Should work fine. This was resolved I thought in later 1.8 versions and then for reasons I am not familiar with, it seems to have returned in nginx 1.9 mainlines.
Let me know if that does/doesn’t do the trick for your server.
A local build is also sending this type of emails to Mailhog (first type listed above). Since it’s been appearing on multiple installs, i’d really love to find the cause of this. Any ideas?
Assuming you have the systemV initialization config, /etc/init.d/nginx, which you should have, then yes, you want to delete the Upstart one. Not to be a broken record on this, but check out the service manpage. Upstart is sometimes.
If you’re having issues after that with auto-loading nginx on startup run: sudo update-rc.d nginx defaults
per this reply from @afonsoduarte.
None of above solutions worked for me, as that file /etc/init/nginx doesn’t exist but I managed to “fix” it by applying below patch to logrotate.xml
git diff
diff --git a/group_vars/all/logrotate.yml b/group_vars/all/logrotate.yml
index c6d2496..bbea7de 100644
--- a/group_vars/all/logrotate.yml
+++ b/group_vars/all/logrotate.yml
@@ -17,4 +17,4 @@ logrotate_scripts:
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
- postrotate: service nginx rotate
+ postrotate: service nginx rotate 2>&1 >/dev/null
I know it could potentially be hiding other messages, but theoretically not errors, and I rather this than getting an annoying email every day
Hope it helps!