creating schedule task without Cron job

前端 未结 5 1283
野趣味
野趣味 2020-12-30 17:29

Scheduled task needs to be created but its not possible to use Cron job (there is a warning from hosting provider that \"running the cron Job more than once within a 45-minu

5条回答
  •  伪装坚强ぢ
    2020-12-30 17:57

    I understand that this question is bit old but I stumbled on it a week ago with this very question and the best and secure option we found was using a Web Service.

    Our context:

    We have our system in both shared hosting and private clouds.

    We need that a script is activated once in a month (there are plans to create more schedules and to allow users to create some predetermined actions)

    Our system provides access to many clients, so, when anyone uses the system it calls for a Web Service via Ajax and doesn't care about the response (after all everything is logged in our database and must run without user interaction)

    What we've done is:

    1 - An ajax call is called upon access in any major screen.

    2 - The Web Service reads a schedule table on our database and calls whatever needs calling

    3 - To avoid many stacked Web Service calls we check datetime with an interval of 10 mins before actually performing any actions

    That's also a way to distribute the load balance and the schedules doesn't affect the system with user interaction.

提交回复
热议问题