logrotate 不生效


登錄服務器查看,發現日志沒有自動切割。去查看micros配置文件:

[root@ecs-11-151 ~]# cat /etc/logrotate.d/micros 
/data/logs/*/*.log {
 rotate 3
 copytruncate
 daily
 dateext
 compress
 missingok
}

看着沒什么問題,手動執行看看

[root@ecs-11-150 logrotate.d]# logrotate -vf micros 
reading config file micros
Allocating hash table for state file, size 15360 B

Handling 1 logs

rotating pattern: /data/logs/*/*.log  forced from command line (3 rotations)
empty log files are rotated, old logs are removed
considering log /data/logs/cloud/accumulationfund-service.log
error: skipping "/data/logs/cloud/accumulationfund-service.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
considering log /data/logs/cloud/bill-cloud.log
error: skipping "/data/logs/cloud/bill-cloud.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.

大意是日志文件所在父目錄有不安全的權限,需要在配置文件設置su項

去查看日志目錄,發現為了方便開發看日志,目錄都改為 777 權限了。

將配置文件改為如下:

[root@ecs-11-151 ~]# cat /etc/logrotate.d/micros 
/data/logs/*/*.log {
 rotate 3
 su root root
 copytruncate
 daily
 dateext
 compress
 missingok
}

手動執行下:

logrotate -vf micros

去看下日志文件有沒有處理

[root@ecs-11-151 service]# ls
apiAuth-service.log             
apiAuth-service.log-20190701.gz 
app-provider.log                
app-provider.log-20190701.gz    


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM