Install logrotate on mac

文章讲述了如何在Mac机器上自动构建Android应用并管理日志,遇到日志文件过大问题后,作者使用logrotate进行备份。在安装和配置logrotate过程中,遇到了状态文件创建错误,通过创建相应目录解决了问题。
摘要由CSDN通过智能技术生成

I have a job to build the android application automatically on a mac machine, and it will output the logs to log files, after some months, the log files are too large, so I want to install the logrotate to backup the old log files every day, and keep the log files for some days.

Install logrotate

brew install logrotate

After install the logrotate with brew, it output the following messages.

To start logrotate now and restart at login:
  brew services start logrotate
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/logrotate/sbin/logrotate /opt/homebrew/etc/logrotate.conf

Setup logrotate

Create a dir /opt/homebrew/etc/logrotate.d, and add the logroate file under this folder.

/path/to/your/logs/*.log {
    daily
    rotate 7
    compress
    missingok
    notifempty
    create 640 username groupname
}

Start logrotate service

From help message after install the logrotate from brew, the start command should like:

brew services start logrotate

But when I run the command, the service was in failed status.
After I run the following command I find that the problem is I need crate one more folder.

  /opt/homebrew/opt/logrotate/sbin/logrotate /opt/homebrew/etc/logrotate.conf

Error message when start logrotate

error: error creating stub state file /opt/homebrew/var/lib/logrotate.status: No such file or directory

After create the dir /opt/homebrew/var/lib, the service can start successfully.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值