小编Bre*_*ard的帖子

systemd 和终端启动程序的区别

我很好奇这些程序之间的区别是什么;通过 systemctl 启用时使用 systemd 启动,而/etc/rc.local通过 CLI 或通过 CLI启动的启动。

例如,我最近在树莓派上使用 shairport-sync。最初,我通过启用 sudo systemctl 的 shairport-sync 将 shairport-sync 设置为启动。

后来我使用其中的一个功能在shairport-sync连接设备之前运行脚本并发布。

令我惊讶的是,执行时的脚本shairport-sync没有kill arecordaplay

然而,当我将通过终端执行,杀死了脚本运行脚本arecordaplay

为了进一步混淆自己,我shairport-sync通过终端杀死并启动它以查看正在发生的事情的输出。当我这样做时,当设备连接并杀死arecordaplay. 所以,作为一个修复我禁用shairport-syncsysmtectl,并设置它在运行/etc/rc.local作为一个快速修复。之后reboot它按我的预期运行。

这让我相信作为一部分运行systemd的程序与通过/etc/rc.local或 CLI启动时运行的程序之间存在一些差异。

为什么会发生这种情况?这是因为运行级别不同吗?什么黑魔法?

设备连接时运行的脚本shairport-sync如下:shairportstart.sh

#!/bin/sh
/usr/bin/sudo /bin/pkill arecord
if [ $(date +%H) -ge "18" -o $(date +%H) -le "7" ]; then
        /usr/bin/amixer set …
Run Code Online (Sandbox Code Playgroud)

shell permissions systemd raspberry-pi raspbian

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

permissions ×1

raspberry-pi ×1

raspbian ×1

shell ×1

systemd ×1