how to run php script automatically every minute without access to that page?

前端 未结 3 391
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 01:23

I\'m developing website that will send email back to user automatically when they registered to my website. I have searched from internet, most of them said that i have to used

3条回答
  •  广开言路
    2021-01-29 02:09

    You can create a PHP file which has a heartbeat event. You put that to sleep using the usleep function with the desired time interval and you can have a list of tasks to be executed (heartbeat tasks), knowing the time rules (when they should run, how often, and so on), and your heartbeat.php will check after each usleep which tasks should be executed and execute it. You can run this heartbeat.php on your server.

    However, I do not see the reason why do you need a cron job, heartbeat or any periodic solution. Why don't you send the emails using php functions exactly when you need to send them?

提交回复
热议问题