I have a LEMP server running Ubuntu 14.04 LTS. (Nginx 1.8)
I got this email about a failed cron job.
Anyone have a solution?
Subject
Cron <root@domain> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
Body
/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
The only edit ive made lately was open /etc/logrotate.conf I uncommented the following line so my log files will be compressed
# uncomment this if you want your log files compressed
compress
Donno if that would have caused it?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
@desiredpersona - Take a look at /etc/logrotate.d/nginx, does your file look like:
/var/log/nginx/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
invoke-rc.d nginx rotate >/dev/null 2>&1
endscript
}
…if so, try swapping out:
invoke-rc.d nginx rotate >/dev/null 2>&1
…with:
nginx -s reload
If that doesn’t work, try swapping it out for:
service nginx rotate
I’ve seen reports that the invoke-rc.d..... line causes issues for others as well. It doesn’t seem to happen on Debian (I use Debian daily as a primary OS on most all personal, client and development deployments).
It would also be advisable to comment the compress line that you remove the comment from as, if your file contains the same command, compress is already defined as an option in the command, thus you shouldn’t need to define it elsewhere.
check logrotation configurations are correct logrotate -f -v /etc/logrotate.d/nginxdf -h
Manually run the logrotationlogrotate -f -v /etc/logrotate.d/nginx to check if it’s working. (failed for me)
in some cases it logrotation may fail due to incorrect ownership of logs.
for me ownership of /var/log/nginx/domain.access.log was www-data:root.
we will need to change it using chown www-data:adm /var/log/nginx/*
running manually logrotate -f -v /etc/logrotate.d/nginx
and this worked and logs rotated successfully.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.