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

前端 未结 11 775
别跟我提以往
别跟我提以往 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条回答
  • 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 ...
    0 讨论(0)
  • 2021-01-13 15:33

    You can use a webcron service to trigger your script.

    0 讨论(0)
  • 2021-01-13 15:39

    Have an outside AppEngine cron job sheduler: Use google AppEngine, it's free. The outside "task" can then "callback" a PHP script of yours.

    I fail to see what's wrong with using the local cron on your machine though aside from it being blocked for you to access.

    0 讨论(0)
  • 2021-01-13 15:42

    I've used windows Task Scheduler to schedule a script on a server I couldn't access cron on before, that worked fine.

    0 讨论(0)
  • 2021-01-13 15:42

    This isn't the best answer as it still requires cron somewhere, but you could always setup another machine that does have cron, like your home computer for instance, to hit a page on your site which triggers the action (using a library like curl or wget).

    0 讨论(0)
提交回复
热议问题