限制jenkins.log或hudson.log的日志大小 [英] Limiting log size of jenkins.log or hudson.log

查看:120
本文介绍了限制jenkins.log或hudson.log的日志大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我同时使用哈德森和詹金斯,而且我有几项工作. 我的hudson.log/jenkins.log文件不时增长.

I use Hudson as well as Jenkins and I have several jobs on them. From time to time my hudson.log/jenkins.log file grows enormously.

我知道可以限制它的大小.请帮助您进行更改,以及必须在哪个文件中进行更改.

I am aware that the size of same can be limited. Please help in how to change and in what file the change has to be made.

推荐答案

您可以使用logrotate.您可以在此kb文章中找到有关logrotate 的更多信息.

You can use logrotate. You can find more information about logrotate on this kb article.

这是在我的系统(/etc/logrotate.d/jenkins)上配置logrotate的方式:

Here is how logrotate is configured on my system (/etc/logrotate.d/jenkins):

/var/log/jenkins/jenkins.log /var/log/jenkins/access_log {
    compress
    dateext
    maxage 365
    rotate 99
    size=+4096k
    notifempty
    missingok
    create 644
    postrotate
      if [ -s /var/run/jenkins.pid ]; then
        JPID=`cat /var/run/jenkins.pid`
        test -n "`find /proc/$JPID -maxdepth 0 -user jenkins 2>/dev/null`" && /bin/kill -s ALRM $JPID || :
      fi
    endscript
}

或者,如果您真的不喜欢信号,并且它使jenkins崩溃,则可以使用

or if you don't really like signals, and it is crashing jenkins for you, you can use the logrotate definition from this debian config.

/var/log/jenkins/jenkins.log {
        weekly
        copytruncate
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
}

这篇关于限制jenkins.log或hudson.log的日志大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆