0

I am creating a web app that requires a job scheduling function for intranet on a Windows server running Apache/PHP/MySQL. For now, we have been executing perl and PHP via .bat files using the built in Windows task scheduler. I would like the scheduling function to be more tightly embedded into the app and not have to utilize the Windows task scheduler. I am considering having a program written that would run as a service to manage the execution of the jobs (service would look at the jobs which would be defined and stored in a MySQL database).

Can anyone speak to this approach and recommend best way to accomplish this?

Kendor
  • 141
  • 6
  • https://dev.mysql.com/doc/refman/5.1/en/events.html ? – Marc B Feb 18 '14 at 20:49
  • 1
    While the suggest from Marc B is good for SQL only jobs, I guess you want to execute some scripts at certain times. Why do you want to reevent the wheel? the task scheduler is meant for that. on linux it's cron – hek2mgl Feb 18 '14 at 20:51

1 Answers1

1

In my opinion there is no real good solution to this. I have done in the past as you have and written a service to manage these sorts of cron jobs but to be honest, I ended up writing the required task not in PHP but in C or C++ as it worked out faster in the actual service itself... thus decoupling app and regular task even more. Even on Linux you would put the task in as a cronjob which is the same deal as task scheduler.

The best approach I have come up with ? I actually had my PHP script (using exec) create the scheduled task so that when I deployed to a new server it happened automatically and was sort of (read very slightly) coupled with the app. And it involved no compiled code either... keeping with the scripted nature of PHP.

chip
  • 599
  • 1
  • 9
  • 20
  • We've decided to create a single Windows scheduled task that would be run to look at our jobs stored in MySQL database... Perhaps we run this task every 30m or every 60m.... – Kendor Feb 21 '14 at 23:48