Is there any way to automatically run PHP script on Hosting web server withour cron?

前端 未结 11 853
别跟我提以往
别跟我提以往 2021-01-13 14:48

I had a script which sends sms alerts everyday. I want it to send automatically send sms by fetching message from database. Can I do it without cron. Is there any other solu

11条回答
  •  萌比男神i
    2021-01-13 15:31

    It's not optimal, but without using any kind of scheduler what you could do is this.

    1. Setup a header file for each page.
    2. Within the header file put your function / procedure that you would like to run.
    3. Make an if statement that checks the if the time is greater then or equal too the time you need your procedure to run and that it has not already been run.

    Down sides of this is that:

    1. There is no guaranteed time of service.
    2. If your website does not get hits, then it might miss the window completely.
    3. Your adding at least 3 function calls to your page, not to mention the function calls required to check if this processes was done today, that might include a call to a MySQL server or flat file ...

提交回复
热议问题