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

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

    Modified version of the above:

    mkdir /etc/cron.15sec
    mkdir /etc/cron.minute
    mkdir /etc/cron.5minute
    

    add to /etc/crontab:

    * * * * * root run-parts /etc/cron.15sec > /dev/null 2> /dev/null
    * * * * * root sleep 15; run-parts /etc/cron.15sec > /dev/null 2> /dev/null
    * * * * * root sleep 30; run-parts /etc/cron.15sec > /dev/null 2> /dev/null
    * * * * * root sleep 45; run-parts /etc/cron.15sec > /dev/null 2> /dev/null
    
    * * * * * root run-parts /etc/cron.minute > /dev/null 2> /dev/null
    */5 * * * * root run-parts /etc/cron.5minute > /dev/null 2> /dev/null
    

提交回复
热议问题