ผมทดสอบการกำหนดค่า logrotate /tmpใน ฉันต้องการ
- เพื่อกำหนดค่านโยบายการ
/tmp/*.logบันทึกเริ่มต้นสำหรับไฟล์โดยใช้ไฟล์ทดสอบการกำหนดค่าของฉัน/tmp/logrotate.conf - ในการจัดการไฟล์บันทึกเฉพาะ
/tmp/special.logด้วยนโยบายที่แตกต่างกันซึ่งกำหนดค่าไว้ในไฟล์ทดสอบการกำหนดค่า logrotate แยก:/tmp/logrotate.d/included
แต่การตอบสนองของ logrotate ต่อการตั้งค่าของฉันคือการพูด
error: /tmp/logrotate.d/included:1 duplicate log entry for /tmp/special.log
ฉันควรทำอย่างไรแตกต่าง
นี่คือฉัน /tmp/logrotate.conf
compress
missingok
notifempty
size 512k
copytruncate
rotate 2
su
# here's my attempt at applying the default policy to all /tmp/*.log
/tmp/*.log {}
# and here I intend to include any overrides
include /tmp/logrotate.d/included
และนี่คือ /tmp/logrotate.d/included
/tmp/special.log {
size 300
}
นี่คือผลลัพธ์การดีบัก
$ sudo logrotate -d ./logrotate.conf
reading config file ./logrotate.conf
including /tmp/logrotate.d/included
reading config file /tmp/logrotate.d/included
error: /tmp/logrotate.d/included:1 duplicate log entry for /tmp/special.log
Handling 2 logs
rotating pattern: /tmp/*.log 524288 bytes (2 rotations)
empty log files are not rotated, old logs are removed
considering log /tmp/normal.log
log does not need rotating
considering log /tmp/special.log
log does not need rotating
rotating pattern: /tmp/special.log 300 bytes (2 rotations)
empty log files are not rotated, old logs are removed
No logs found. Rotation not needed.
- ข้อผิดพลาดทำให้ฉันประหลาดใจเพราะฉันคิดว่าตามหน้า man "ไฟล์ config ในภายหลังอาจแทนที่ตัวเลือกที่ให้ไว้ในไฟล์ก่อนหน้าดังนั้นลำดับที่แสดงไฟล์กำหนดค่า logrotate มีความสำคัญ"
- ทำไมถึงพูดตอนท้ายเมื่อจัดการรูปแบบ
/tmp/special.logที่ไม่พบบันทึก ไฟล์/tmp/special.logมีอยู่และมีขนาดใหญ่กว่า 300 ไบต์
/tmpค่ะ ด้วยไดเร็กทอรีการทำงานปัจจุบันของ/tmpฉันรันคำสั่งนี้: sudo logrotate -d ./logrotate.conf <ประโยคต่อไปนี้:> normal.logและspecial.logเป็นของฉัน logrotate.confและlogrotated.d/includedเป็นเจ้าของโดย root เพราะเมื่อทุกอย่างเป็นของฉันมีปัญหาสิทธิ์ในการเปลี่ยนคุณสมบัติบางอย่างในขณะที่ logrotate กำลังทำงานอยู่
switching euid to 0 and egid to 0 ... error: error switching euid to 0 and egid to 0: Operation not permitted
/tmp/logrotate.dคุณแค่ทดสอบจากที่นั่น/etc/logrotate.dใช่ไหม คุณสามารถโพสต์คำสั่งที่คุณใช้เมื่อคุณทำการทดสอบได้หรือไม่?