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

前端 未结 11 774
别跟我提以往
别跟我提以往 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:19

    You have a couple of options:

    • Emulate cron behavior: In your php code, check if the page was loaded at, or close to, the time you wish to schedule the sendout for, if the messages havent been sent yet, load the script that sends the messages in the background and flag them as sent.

    • As others have suggested, setup a cronjob somewhere else that will execute a script on your server by fetching the url via http (by using wget for example)

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

    If you can't set up a cron job on the server, do it on a client you have access to (like your computer) so that it does a request when you need the script to be run.

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

    set up a cron task elsewhere, have it request the script that sends the alerts.

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

    you can include your script and have it run every time some one visits your homepage/login page etc... set up a table in mysql called time. query the database everytime the page is visited. if (time argument) {run the script in the background, update the new time in the DB}

    All you have to do is fuigure out how often you want to send out your sms emails. Ex. 1 time per day database row "time" has a date in it. the date is lets say 24 hours ago. if the db row "time" is less than or equal to today minus one day 1 day , then run your script. this will run your script once per day.

    The draw back -> someone needs to visit your site atleast once per day.

    What is your website URL? What are you doing?

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

    Using third party webcron like easycron.com.

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

    In simple words, you can't run php scripts without using some sort of scheduler or cron...

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