我正在运行Ubuntu16.04LTS中的用户级服务。例如,我的test.service位于~/.config/systemd/user/test.service。
我能够通过以下方式运行服务
systemctl --user start test.target然而,当我尝试使用journalctl读取它的日志时,我得到了以下错误消息:
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用于用户的特定单元?
发布于 2016-11-15 03:49:21
在较早的systemd版本中,您将不得不使用journalctl --user --user-unit=SERVICENAME (在较新的版本中,journalctl --user -u SERVICENAME可以正常工作)。
但是,只有当Storage部分的[Journal]部分的/etc/systemd/journald.conf指令设置为persistent (而不是auto或volatile)时,这才有效。编辑配置文件后重新启动,用户将能够看到日志。
更多信息:https://www.freedesktop.org/software/systemd/man/journald.conf.html https://lists.freedesktop.org/archives/systemd-devel/2016-October/037554.html
发布于 2023-02-13 09:42:53
您可以创建一个bash脚本,它使用特定的参数在sudo journalctl上运行,保护该脚本不被写入,并给予不需要密码的作为sudo运行该脚本的特定权限。例如,在/etc/sudoers中添加条目
ALL ALL = NOPASSWD: /etc/show_journal.sh
而不是您可以编写特定的linux用户。
https://serverfault.com/questions/806469
复制相似问题