You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下Twonky Server通过systemd自启动的权限问题及解决

Fixing Twonky Server Systemd Auto-Start EACCES (Exit Code 13) on Ubuntu

I ran into a frustrating issue while setting up Twonky Server on Ubuntu recently: the server worked fine when started manually, but the custom twonkyserver.service file I created in /etc/systemd/system/ wouldn't let it auto-start with systemd. I kept getting a vague error about not being able to access the PID file /var/run/mediaserver.pid, with an exit code of 13 (that's the EACCES permission denied error) — even though the service was running as root!

The fix turned out to be simple: explicitly define the PIDFile directive in the systemd service file. This tells systemd exactly where to look for the PID file, ensuring it can properly manage the service's lifecycle and avoid permission conflicts.

Here's the working twonkyserver.service file that resolved the issue:

[Unit]
Description=Twonky Server Service
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/twonky/twonky.sh start
ExecStop=/usr/local/twonky/twonky.sh stop
ExecReload=/usr/local/twonky/twonky.sh reload
ExecRestart=/usr/local/twonky/twonky.sh restart
PIDFile=/var/run/mediaserver.pid
Restart=on-failure

[Install]
WantedBy=multi-user.target

Once you've updated the service file, don't forget to reload systemd and enable the service to make sure the changes take effect:

sudo systemctl daemon-reload
sudo systemctl enable twonkyserver.service

Without the PIDFile directive, systemd might not correctly track the PID file generated by Twonky's startup script, leading to unexpected permission issues even when running as root. Specifying it explicitly aligns systemd's expectations with the script's behavior, fixing the auto-start problem entirely.

内容的提问来源于stack exchange,提问作者razfaz32

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 07:27:27