ExecStop不会在服务中工作

时间:2015-10-01 03:00:27

标签: linux raspberry-pi archlinux systemd

我正在覆盆子pi上实现LED的基本闪烁。基本上我的想法是当我运行计时器时,pi开始闪烁,当我停止计时器时,pi会自动停用。我有三个bash脚本(activate.sh,deactivate.sh,toggle.sh)。

1.toggle.timer

[Unit]
Description="toggle timer
Requires= activate.service
After= activate.service

[Timer] 
OnActiveSec=0.5
OnUnitActiveSec=500ms

[Install]
WantedBy=multi-user.target

2.toggle.service

# toggle.service companion to toggle.timer
[Unit]
Description = LED Toggle Service Unit
Requires = activate.service
After = activate.service

[Service]
Type = oneshot
ExecStart = /usr/local/bin/toggle.sh
StartLimitIntervals=10s
StartLimitBurst=30

[Install]
WantedBy=multi-user.target
3. activate.service
[Unit]
Description=LED activate service
StopWhenUnneeded=true


[Service]
Type=oneshot
RemainAfterExit= yes

ExecStart= /usr/local/bin/activate.sh
ExecStop= /usr/local/bin/deactivate.sh


[Install]
WantedBy=multi-user.target

我测试了我的三个脚本,它们都运行良好。 但是,当我执行systemctl start toggle.timer时,切换服务启动并且一切正常。当我停止时,切换不会停止,而activate.service也不会运行我的ExecStop脚本。我不知道它有什么问题。

0 个答案:

没有答案