Running a script every second
Yan Seiner
yan at seiner.com
Wed Mar 5 17:40:54 UTC 2014
On 03/05/2014 09:14 AM, Yan Seiner wrote:
> I am trying to run a script every second. I set up two scripts:
>
> first script (the one that does the work)
>
> #!/bin/ash
>
> update() {
> ....
> }
>
> trap 'update' HUP
>
> mknod /tmp/dummyfifo p
>
> while true; do
> read < /tmp/dummyfifo > /dev/null 2>&1
> done
>
> and now the trigger script:
>
> #!/bin/ash
>
> /bin/watch -t -n 1 killall -HUP update > /dev/null 2>&1
>
> The problem is that the 'read' generates a
>
> /usr/bin/update: line 1: can't open /tmp/dummyfifo: Interrupted system
> call
>
> every time watch triggers the script. Other than that it works
> perfectly.
>
> I've tried various other things but this works best, except for the
> system call clogging up the terminal and logfiles.
>
Here's what works:
trap 'update' HUP
mknod /tmp/dummyfifo p
cat /tmp/dummyfifo &
pid=$!
while true; do
wait $pid
done
More information about the busybox
mailing list