
저는 큰 로그 파일을 생성하는 프로그램을 작업 중입니다.
logrotate로 처리하고 싶습니다.
이것은 내가 설정한 구성입니다 /etc/logrotate.d/
.
/var/log/myproject.log {
hourly
maxsize 1
rotate 6
missingok
notifempty
compress
nocreate
copytruncate
su www-data www-data
}
( /var/log/myproject.log
소유자 있음 www-data
)
명령
sudo logrotate -vf /etc/logrotate.conf
그리고
sudo logrotate -vf /etc/logrotate.d/myproject
로그를 올바르게 회전하십시오.
그러나 호출한 후에는 /etc/cron.hourly
비어 있습니다. 이는 logrotate가 시간별로 호출되지 않음을 의미합니다.
logrotate
에 스크립트가 있다는 것이 보장됩니까/etc/cron.daily
?스크립트가 로그 파일의 업데이트 빈도를 확인합니까? 즉 ,
logrotate
스크립트가 있고/etc/cron.daily
일부 로그 파일에 대해 설정을 지정한X
경우 매일 또는 매주 순환됩니까?/etc/logrotate.d/
weekly
X
/etc/cron.daily/logrotate
에 복사하여 붙여넣기만 하면 되나요/etc/cron.hourly/
? 잘라서 붙여넣을 수 있나요?0anacron
에 파일을 추가해야 합니까/etc/cron.hourly/
?시간별 로깅을 활성화하려면 다른 작업을 수행해야 합니까?
답변1
아니요.
-
Each configuration file can set global options (local definitions override global ones, and later definitions override earlier ones)
그렇죠.
다시 맨페이지에서:
hourly Log files are rotated every hour. Note that usually logrotate is configured to be run by cron daily. You have to change this configuration and run logrotate hourly to be able to really rotate logs hourly.
그렇군요. 스크립트를 옮겨야 합니다. 내 시스템의 스크립트를 검사해 보니
cron.daily
스크립트를 옮기는 것이 잘 작동할 것 같습니다.