开发者

Are there any platform agnostic ways to schedule tasks using PHP?

开发者 https://www.devze.com 2023-03-28 06:11 出处:网络
I\'m currently looking for a way that I can build a scheduling system that could run scripts at a certain date and/or time, and do it in such a way that it doesn\'t care what operating system it\'s li

I'm currently looking for a way that I can build a scheduling system that could run scripts at a certain date and/or time, and do it in such a way that it doesn't care what operating system it's living on. I know with linux/unix, I can add enteries using cron, but with other OS's? NOt so much.

Also if there's a way to have it execute without relying on external software such as c开发者_运维知识库ron, I'd be interested to learn about those options as well, although I realize that's probably a stretch with PHP.

Thanks for your help in this matter!


If you write a persistent server in PHP that runs 24 hours a day, then scheduling tasks is easy; loop forever and check if there are any tasks scheduled for the current time each second and run them... run the code or spawn a process to do so with exec.

Assuming you did not intend to write a persistent server in PHP, then no, there's no platform agnostic way to schedule tasks with the operating system.

0

精彩评论

暂无评论...
验证码 换一张
取 消