我应该如何从非 root Debian Linux 守护进程登录? [英] How should I log from a non-root Debian Linux daemon?

查看:33
本文介绍了我应该如何从非 root Debian Linux 守护进程登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个新的守护进程,它将托管在 Debian Linux 上.

I'm writing a new daemon, which will be hosted on Debian Linux.

我发现/var/log 只有 root 写入权限,所以我的守护进程无法在那里写入日志文件.

I've found that /var/log has root only write permissions, so my daemon cannot write log files there.

但是,如果它在那里写入,它似乎将获得自动日志轮换,并且还可以按照用户的预期工作.

However, if it writes there, it appears it will gain automatic log rotation, and also work as a user might expect.

对于守护程序来说,写入出现在/var/log 中的日志条目而不必以 root 身份运行的推荐方法是什么?

What is the recommended way for a daemon to write log entries that appear in /var/log, without having to be run as root?

守护进程是一个网络服务器,因此日志流量将类似于 Apache.

The daemon is a webserver, so the log traffic will be similar to Apache.

推荐答案

你应该创建一个子目录,比如 /var/log/mydaemon 拥有守护进程的用户所有权

You should create a subdirectory like /var/log/mydaemon having the daemon's user ownership

这篇关于我应该如何从非 root Debian Linux 守护进程登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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