首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何允许用户使用日志查看特定于用户的系统服务日志?

如何允许用户使用日志查看特定于用户的系统服务日志?
EN

Server Fault用户
提问于 2016-10-01 02:58:13
回答 2查看 43.2K关注 0票数 45

我正在运行Ubuntu16.04LTS中的用户级服务。例如,我的test.service位于~/.config/systemd/user/test.service

我能够通过以下方式运行服务

代码语言:javascript
复制
systemctl --user start test.target

然而,当我尝试使用journalctl读取它的日志时,我得到了以下错误消息:

代码语言:javascript
复制
journalctl --user -u test.service
Hint: You are currently not seeing messages from other users and the system.
  Users in the 'systemd-journal' group can see all messages. Pass -q to
  turn off this notice.
No journal files were opened due to insufficient permissions.

如何将journalctl用于用户的特定单元?

EN

回答 2

Server Fault用户

回答已采纳

发布于 2016-11-15 03:49:21

在较早的systemd版本中,您将不得不使用journalctl --user --user-unit=SERVICENAME (在较新的版本中,journalctl --user -u SERVICENAME可以正常工作)。

但是,只有当Storage部分的[Journal]部分的/etc/systemd/journald.conf指令设置为persistent (而不是autovolatile)时,这才有效。编辑配置文件后重新启动,用户将能够看到日志。

更多信息:https://www.freedesktop.org/software/systemd/man/journald.conf.html https://lists.freedesktop.org/archives/systemd-devel/2016-October/037554.html

票数 26
EN

Server Fault用户

发布于 2023-02-13 09:42:53

您可以创建一个bash脚本,它使用特定的参数在sudo journalctl上运行,保护该脚本不被写入,并给予不需要密码的作为sudo运行该脚本的特定权限。例如,在/etc/sudoers中添加条目

ALL ALL = NOPASSWD: /etc/show_journal.sh

而不是您可以编写特定的linux用户。

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/806469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档