Question

I'm working on a application where user can schedule date and time, when some reports should be generated.

He/She sets a date and time and type of report.

I have a piece of code to generate report. Now how can this be scheduled to run at user specified time and date.

I know about linux cron but please keep in mind that user selects date/time and type of report and the script should run at that time. Obviously all of this is automated. And there are going to be thousands of users using this feature.

Is there any alternative ( to linux cron ) in PHP to accomplish this?? What is the best way to do this?

Thanks, Sash

Was it helpful?

Solution

There is two ways to do that :

First : use cron script to run in every minute to check if there is report that needs to be generated. If you dont wont to run that script every minute, force user to choose time like this : 10:00 , 10:15, 10:30... and set 15 min interval.

Second : generate script with infinite loop that is run via console like php <script_name.php> a it have to do same job as cron script in that loop. Bad solution from my opinion

I will stick with cron job solution for numeros of reasons. ;) So at the end use cron for that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top