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

前端 未结 9 604
佛祖请我去吃肉
佛祖请我去吃肉 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:21

    Use nanosleep(2). It uses structure timespec that is used to specify intervals of time with nanosecond precision.

    struct timespec {
               time_t tv_sec;        /* seconds */
               long   tv_nsec;       /* nanoseconds */
           };
    

提交回复
热议问题