/var/www/example/current/log/example.log { daily missingok rotate 1 delaycompress compress notifempty copytruncate}
我检查了Logrotate not working并检查了我的配置,并没有找到任何重复的应用程序服务器或Nginx条目.下面是我的Nginx logrotate文件的定义.
/var/log/Nginx/*.log { daily missingok rotate 3 compress delaycompress notifempty create 0640 www-data adm sharedscripts postrotate if [ -s /var/run/Nginx.pID ]; then kill -USR1 `cat /var/run/Nginx.pID` fi endscript}
我的日志仍然是用* .log.1编写而不是* .log任何人都可以帮忙吗?我想知道这里有什么问题.
以下是调试模式下的logrotate命令输出.
logrotate --force -d /etc/logrotate.d/Nginxreading config file /etc/logrotate.d/NginxHandling 1 logsrotating pattern: /var/log/Nginx/*.log forced from command line (3 rotations)empty log files are not rotated,old logs are removedconsIDering log /var/log/Nginx/access.log log does not need rotatingconsIDering log /var/log/Nginx/elasticsearch.access.log log does not need rotatingconsIDering log /var/log/Nginx/error.log log does not need rotatingconsIDering log /var/log/Nginx/grafana.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-admin.access.log log needs rotatingconsIDering log /var/log/Nginx/example-admin.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-administrators.access.log log needs rotatingconsIDering log /var/log/Nginx/example-administrators.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-alot.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-alot.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-API_clIEnts.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-API_clIEnts.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-assets.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-backgrounds.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-backgrounds.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-blog.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-blog.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-blog-service.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-blog-service.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-boards.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-boards.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-bolt.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-bolt.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-bonobo.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-bonobo.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-boss.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-boss.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-callbacks.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-callbacks.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-cashIEr.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-cashIEr.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-dashboard-old.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-dcl_shipments.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-dcl_shipments.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-device-registry.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-device-registry.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-docs.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-exports.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-exports.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-fake-API.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-fake-API.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-fashion-police.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-fashion-police.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-flight-recorder.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-flight-recorder.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-gone.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-gone.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-go-portal.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-go-portal.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-help-service.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-help-service.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-kfc.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-kfc.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-kredits.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-kredits.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-login.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-login.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-manual-activations.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-manual-activations.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-maps.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-mobile-API.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-mobile-API.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-mqttproxy.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-mqttproxy.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-network-coverage.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-network-coverage.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-package_tracker.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-package_tracker.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-people.access.log log needs rotatingconsIDering log /var/log/Nginx/example-people.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-postman-pat.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-postman-pat.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-premium.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-premium.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-push-notifications.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-push-notifications.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-referrific.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-referrific.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-services.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-services.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-store.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-store.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-subs.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-subs.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-updates.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-updates.error.log log does not need rotatingconsIDering log /var/log/Nginx/example-website.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-wildcard-redirect.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-Zendesk-proxy.access.log log does not need rotatingconsIDering log /var/log/Nginx/example-Zendesk-proxy.error.log log does not need rotatingconsIDering log /var/log/Nginx/kibana.access.log log does not need rotatingconsIDering log /var/log/Nginx/prometheus.access.log log does not need rotatingconsIDering log /var/log/Nginx/prometheus_alertmanager.access.log log does not need rotatingconsIDering log /var/log/Nginx/prometheus_statsd_brIDge.access.log log does not need rotatingrotating log /var/log/Nginx/example-admin.access.log,log->rotateCount is 3dateext suffix '-20170104'glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'compressing log with: /bin/gziprenaming /var/log/Nginx/example-admin.access.log.3.gz to /var/log/Nginx/example-admin.access.log.4.gz (rotatecount 3,logstart 1,i 3),renaming /var/log/Nginx/example-admin.access.log.2.gz to /var/log/Nginx/example-admin.access.log.3.gz (rotatecount 3,i 2),renaming /var/log/Nginx/example-admin.access.log.1.gz to /var/log/Nginx/example-admin.access.log.2.gz (rotatecount 3,i 1),renaming /var/log/Nginx/example-admin.access.log.0.gz to /var/log/Nginx/example-admin.access.log.1.gz (rotatecount 3,i 0),rotating log /var/log/Nginx/example-administrators.access.log,log->rotateCount is 3dateext suffix '-20170104'glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'compressing log with: /bin/gziprenaming /var/log/Nginx/example-administrators.access.log.3.gz to /var/log/Nginx/example-administrators.access.log.4.gz (rotatecount 3,renaming /var/log/Nginx/example-administrators.access.log.2.gz to /var/log/Nginx/example-administrators.access.log.3.gz (rotatecount 3,renaming /var/log/Nginx/example-administrators.access.log.1.gz to /var/log/Nginx/example-administrators.access.log.2.gz (rotatecount 3,renaming /var/log/Nginx/example-administrators.access.log.0.gz to /var/log/Nginx/example-administrators.access.log.1.gz (rotatecount 3,rotating log /var/log/Nginx/example-people.access.log,log->rotateCount is 3dateext suffix '-20170104'glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'compressing log with: /bin/gziprenaming /var/log/Nginx/example-people.access.log.3.gz to /var/log/Nginx/example-people.access.log.4.gz (rotatecount 3,renaming /var/log/Nginx/example-people.access.log.2.gz to /var/log/Nginx/example-people.access.log.3.gz (rotatecount 3,renaming /var/log/Nginx/example-people.access.log.1.gz to /var/log/Nginx/example-people.access.log.2.gz (rotatecount 3,renaming /var/log/Nginx/example-people.access.log.0.gz to /var/log/Nginx/example-people.access.log.1.gz (rotatecount 3,renaming /var/log/Nginx/example-admin.access.log to /var/log/Nginx/example-admin.access.log.1creating new /var/log/Nginx/example-admin.access.log mode = 0640 uID = 33 gID = 4renaming /var/log/Nginx/example-administrators.access.log to /var/log/Nginx/example-administrators.access.log.1creating new /var/log/Nginx/example-administrators.access.log mode = 0640 uID = 33 gID = 4renaming /var/log/Nginx/example-people.access.log to /var/log/Nginx/example-people.access.log.1creating new /var/log/Nginx/example-people.access.log mode = 0640 uID = 33 gID = 4running postrotate scriptrunning script with arg /var/log/Nginx/*.log : " if [ -s /var/run/Nginx.pID ]; then kill -USR1 `cat /var/run/Nginx.pID` fi"removing old log /var/log/Nginx/example-admin.access.log.4.gzerror: error opening /var/log/Nginx/example-admin.access.log.4.gz: No such file or directory
当我强制logrotate时,我最终会遇到错误.
sudo logrotate -f /etc/logrotate.conflogrotate_script: 2: logrotate_script: /etc/init.d/example-admin: not founderror: error running non-shared postrotate script for /var/www/admin/current/log/example-admin.log of '/var/www/admin/current/log/example-admin.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-administrators: not founderror: error running non-shared postrotate script for /var/www/administrators/current/log/example-administrators.log of '/var/www/administrators/current/log/example-administrators.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-alot: not founderror: error running non-shared postrotate script for /var/www/alot/current/log/example-alot.log of '/var/www/alot/current/log/example-alot.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-bonobo: not founderror: error running non-shared postrotate script for /var/www/bonobo/current/log/example-bonobo.log of '/var/www/bonobo/current/log/example-bonobo.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-cashIEr: not founderror: error running non-shared postrotate script for /var/www/cashIEr/current/log/example-cashIEr.log of '/var/www/cashIEr/current/log/example-cashIEr.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-dcl-shipments: not founderror: error running non-shared postrotate script for /var/www/dcl_shipments/current/log/example-dcl_shipments.log of '/var/www/dcl_shipments/current/log/example-dcl_shipments.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-people: not founderror: error running non-shared postrotate script for /var/www/people/current/log/example-people.log of '/var/www/people/current/log/example-people.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-store: not founderror: error running non-shared postrotate script for /var/www/store/current/log/example-store.log of '/var/www/store/current/log/example-store.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-storefront: not founderror: error running non-shared postrotate script for /var/www/storefront/current/log/example-storefront.log of '/var/www/storefront/current/log/example-storefront.log 'logrotate_script: 2: logrotate_script: /etc/init.d/example-subs: not founderror: error running non-shared postrotate script for /var/www/subs/current/log/example-subs.log of '/var/www/subs/current/log/example-subs.log '
以下是调试模式下的logrotate命令输出.
sudo logrotate -dv /etc/logrotate.d/example-alotreading config file /etc/logrotate.d/example-alotHandling 1 logsrotating pattern: /var/www/alot/current/log/example-alot.log after 1 days (1 rotations)empty log files are not rotated,old logs are removedconsIDering log /var/www/alot/current/log/example-alot.log log needs rotatingrotating log /var/www/alot/current/log/example-alot.log,log->rotateCount is 1dateext suffix '-20170105'glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'compressing log with: /bin/gziprenaming /var/www/alot/current/log/example-alot.log.1.gz to /var/www/alot/current/log/example-alot.log.2.gz (rotatecount 1,renaming /var/www/alot/current/log/example-alot.log.0.gz to /var/www/alot/current/log/example-alot.log.1.gz (rotatecount 1,copying /var/www/alot/current/log/example-alot.log to /var/www/alot/current/log/example-alot.log.1truncating /var/www/alot/current/log/example-alot.logrunning postrotate scriptrunning script with arg /var/www/alot/current/log/example-alot.log: " echo "Appending to" example-alot > /var/www/alot/current/log/example-alot.log /etc/init.d/example-alot reload >> /dev/null"removing old log /var/www/alot/current/log/example-alot.log.2.gzsudo logrotate -dv /etc/logrotate.d/example-subsreading config file /etc/logrotate.d/example-subsHandling 1 logsrotating pattern: /var/www/subs/current/log/example-subs.log after 1 days (1 rotations)empty log files are not rotated,old logs are removedconsIDering log /var/www/subs/current/log/example-subs.log log does not need rotating解决方法 如果Nginx正在写入旧日志文件,则可能会发生这种情况,因为您的postrotate *** 作无效.
您是否检查/var/run/Nginx.pID是否存在且包含正确的pID?
而且你可以试试
logrotate --force -d /etc/logrotate.d/Nginx
然后检查输出.它给出了很好的指示.
总结以上是内存溢出为你收集整理的linux – logrotate不写日志到正确的文件全部内容,希望文章能够帮你解决linux – logrotate不写日志到正确的文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)