Running a PHP script every 5 minutes and avoiding race conditions

后端 未结 5 1311
无人及你
无人及你 2021-01-12 12:13

I have a php script that needs to run once every 5 minutes. Currently I\'m using a cron job to run it (and it works great) but my host only allows a minimum time of 15 minut

5条回答
  •  感情败类
    2021-01-12 12:24

    Lame answer for a lame situation (the ISP, not the poster). Schedule 12 cron jobs, all calling the same script, each running once per hour, but calling at a different 5 minute mark.

    00 * * * * root echo "run at :00 of every hour"
    05 * * * * root echo "run at :05 of every hour"
    10 * * * * root echo "run at :10 of every hour"
    

    etc until :55. But I stand by my original comment - find a new ISP :)

提交回复
热议问题