How to get a unix script to run every 15 seconds?

前端 未结 9 606
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 19:35

I\'ve seen a few solutions, including watch and simply running a looping (and sleeping) script in the background, but nothing has been ideal.

I have a script that ne

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 20:09

    Won't running this in the background do it?

    #!/bin/sh
    while [ 1 ]; do
        echo "Hell yeah!" &
        sleep 15
    done
    

    This is about as efficient as it gets. The important part only gets executed every 15 seconds and the script sleeps the rest of the time (thus not wasting cycles).

提交回复
热议问题