What options are there for executing a PHP script at a certain time every day?

前端 未结 9 695
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 06:58

I have a PHP script that needs to be run at certain times every weekday. Is cron or Windows task scheduler the only way to do this?
Is there a way to set th

相关标签:
9条回答
  • 2020-12-12 07:40

    Apart from cron or Scheduled Tasks, you can have your PHP script to always run it. The process should sleep (within a loop) until the time has reached. Then, the process could execute the remaining functions/methods. Or, you can set up another script (which will act as a daemon) to check for the time and execute the other script.

    0 讨论(0)
  • 2020-12-12 07:41

    You probably want to use cron (or windows scheduled tasks).

    If you really wanted, you could set up another php script to run continuously with an infinite loop (with a sleep command inside the loop, say for 30 seconds or so) and then when you reach your desired day/time execute the other script via a shell command call. While possible, I can't think if a single good reason to use this method rather than cron/scheduled tasks

    0 讨论(0)
  • 2020-12-12 07:44

    If this is in a remote server you do not have cron access to, you can setup cron/windows scheduler on your computer, to open a web browser to the page that contains the script you wish to run

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