2

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 cron, 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!

canadiancreed
  • 1,966
  • 6
  • 41
  • 58
  • hosting php on anything but *nix is non optimal –  Aug 14 '11 at 23:25
  • @dagon agreed. Sadly convincing potential clients to switch architectures usually kills off any potential adoption of an application. – canadiancreed Aug 14 '11 at 23:27
  • 1
    I like writing SAAS apps, I dictate the hosting environment –  Aug 14 '11 at 23:29
  • 2
    Have you considered online scheduling services such as scheduler.codeeffects.com or wsscheduler.com? Bunch of them are free and reliable. – Kizz Aug 14 '11 at 23:46
  • @kizz I have not, but it would at least remove the platform side of things. I'll give them a looksee. – canadiancreed Aug 14 '11 at 23:57

1 Answers1

1

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.

Dan Grossman
  • 51,866
  • 10
  • 112
  • 101
  • php daemons, functional but problematic –  Aug 14 '11 at 23:26
  • Indeed. I've actually never looked into that side of PHP before, was always taught that if you are getting into things that require exec(), it's time to look at a language that operates closer to the hardware level then PHP does. – canadiancreed Aug 14 '11 at 23:58
  • 1
    i agree but optimal coding often clashes with business expedience. –  Aug 15 '11 at 00:28