在服務(wù)器端設(shè)置 logrotate

2018-11-11 14:02 更新

工作原理

自 3.1 版本以后,seaf-server 和 ccnet-server 支持通過接收 SIGUR1 信號來管理日志文件。

這個功能在你需要剪切日志文件但是不想關(guān)閉服務(wù)器的時候非常有用。

注意: 此功能在 Windows 下并不適用

logrotate 默認配置

對于 Debian, logrotate 默認存儲在 /etc/logrotate.d/

配置示例

假設(shè)你的 ccnet-server 的日志文件是 /home/haiwen/logs/ccnet.log, ccnet-server 進程的 pidfile 是 /home/haiwen/pids/ccnet.pid. seaf-server's 的日志文件是 /home/haiwen/logs/seaf-server.log, seaf-server 進程的 pidfile 是 /home/haiwen/pids/seaf-server.pid:

則請按如下配置 logroate:

/home/haiwen/logs/seaf-server.log
{
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        sharedscripts
        postrotate
                [ ! -f /home/haiwen/pids/seaf-server.pid ] || kill -USR1 `cat /home/haiwen/pids/seaf-server.pid`
        endscript
}

/home/haiwen/logs/ccnet.log
{
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        sharedscripts
        postrotate
                [ ! -f /home/haiwen/pids/ccnet.pid ] || kill -USR1 `cat /home/haiwen/pids/ccnet.pid`
        endscript
}

對于 Debian 用戶, 可以將以上配置文件存儲在 /etc/logrotate.d/seafile

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號