Skip to content

Instantly share code, notes, and snippets.

@kujiy
Created July 27, 2016 06:08
Show Gist options
  • Save kujiy/3f11333f0939a674bd7e807a09e4accd to your computer and use it in GitHub Desktop.
Save kujiy/3f11333f0939a674bd7e807a09e4accd to your computer and use it in GitHub Desktop.
# /etc/logrotate.d/php
/var/log/php_errors.log {
rotate 4
missingok
notifempty
sharedscripts
delaycompress
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
}
@kujiy
Copy link
Author

kujiy commented Jul 27, 2016

Activate php error log

php.ini

[root@ra]# cat /etc/php.ini | grep _errors.log
error_log = /var/log/php_errors.log 
apachectl graceful

logrotate

[root@ra]# cat /etc/logrotate.d/php 
/var/log/php_errors.log {
    rotate 4
    missingok
    notifempty
    sharedscripts
    delaycompress
    postrotate
        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    endscript
}

TEST

#dry run
logrotate -dv /etc/logrotate.d/php
# Force execute
logrotate -f /etc/logrotate.d/php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment