#!/bin/bash
#this file is /bin/flashled.sh
#let's exit if another instance is already running
if [[ $(pgrep -c "$0" ) -gt 1 ]]; then exit ;fi
... ... ...
#!/bin/bash
#this file is /bin/flashled.sh
#write in your /etc/rc.local: /bin/flashled.sh & ; disown
#or let it start by init.
while :
do
kill -SIGSTOP $$ # halt and wait
... ... # your commands here
sleep $TIME # choose your own value here instead of $TIME
done
1 回答
这不是解决方案,而是一种解决方法:
一种方法(简单)是像这样开始你的脚本"/bin/flashled.sh"
但是,在某些边界情况下,这可能会有点竞争条件(bash有点慢,因此无法确定这将始终有效)但它可能在您的情况下完美地工作 .
另一个(更稳固但更多的代码)是这样开始“/bin/flashled.sh”:
在启动过程中启动它(例如,通过/etc/rc.local),这样它就会等待信号继续...无论它有多少“继续”信号(它们没有排队),只要它们在$ TIME内
相应地更改您的udev规则: