安装rpm时创建日志文件 [英] Create log file when installing rpm

查看:128
本文介绍了安装rpm时创建日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 rpm 规范文件中创建日志文件的最佳方法是什么?我正在创建的服务在非特权用户下运行,因此无法在/var/log/中创建文件.

What the best way to create a log file in an rpm spec file? The service I'm creating runs under an unprivileged user so cannot create files in /var/log/.

推荐答案

您可以创建 /var/log/myservice/ 目录并使其归您的用户所有.在 %install 或 make install 中:(忽略 buildroot 等)

You could create /var/log/myservice/ directory and make it owned by your user. Inside %install or make install: (ignoring buildroot & such)

install -d /var/log/myservice -o serviceuser -m 750

这假设您正在运行类似于 apache 的服务,通常以用户 apache 运行,并且仍然将日志放在 var/log/apache

This assumes you are running your service similarly to apache which often runs as user apache and still puts logs in var/log/apache

然后在您的规范文件中为 /var/log/myservice 添加相应的规则.

Then add the corresponding rule for /var/log/myservice in your spec file.

%dir /var/log/myservice

这篇关于安装rpm时创建日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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