notes
notes copied to clipboard
xxx.service Failed to connect stdout to the journal socket, ignoring: Permission denied
场景
某些程序在启动时,会报出 (xxx 为你的程序名)
xxx.service Failed to connect stdout to the journal socket, ignoring: Permission denied
说明:
systemd 启动该程序期间,默认将标准输出和标准错误之类的定向输出给 journal。
如果权限不足,就会报出上述的错误。这个只是启动时的信息,并不是程序自身的日志机制。
一般来说等启动完成之后,程序自己的日志机制才会生效。在此之前都是由 systemd 在处理。
方法1
chmod 777 /run/systemd/journal/stdout
systemctl stop xxx.service
systemctl start xxx.service
方法2
在 /usr/lib/systemd/system/ 下打开 xxx.service
找到以下的代码,如果没有的,自行添加
StandardOutput=journal
StandardError=journal
更改为你自定义的路径,也可以设置为 syslog
StandardOutput=file:/path/to/your/custom.log
StandardError=file:/path/to/your/custom.log
重启服务 (有多余步骤,主要防止修改不生效的问题)
systemctl daemon-reload
systemctl reset-failed
systemctl stop xxx.service
systemctl disable xxx.service
systemctl enable xxx.service
systemctl start xxx.service