Welcome Guest, Not a member yet? Register   Sign In
How to schedule tasks in PHP ? (Storing & running techniques)
#1

[eluser]Songoko20000[/eluser]
Hi all
I am currently working on a PHP project. Basically I have few actions that I want to run automatically. I will be using a cron job to do the trick. The cron job will run a php script file.

Till now everything seems normal. Now I have created a table in my database and have stored the actions that I need to run in it. For example I need to do the following:

1-Create a sample file (5 times).

2-Upload all sample files (1 time).

3-send mail (continuous).

So I will store in my table the controller and action for (creating a sample file) and set its repeating time to 5 and set also its execution time. The same will be done for the other two actions.

Now the script file is run every minute. In the script file I will select all records that from the table that have an execution time equal to the current time then run them.

I have a UI screen for controlling the scheduled tasks. Simply the user can choose from a drop down the task which he like to add to the table and he specifies the time and repetition of the task. The user can view all the tasks in the table and can modify or delete any of them. The tasks themselves are defined once and are loaded in the dropdown. The user can then choose any number of tasks to add to the cronjobs table in the database. The frequency of the changes can depend on the business need as we are still in the development phase.

Now to make things just clear this system actually works but I was thinking about a better or improved scheduler techniques. Storing the scheduled actions in a table sound like a good idea but I was wondering if there was a superior approach ?!
#2

[eluser]Bigil Michael[/eluser]
please post cron job code




Theme © iAndrew 2016 - Forum software by © MyBB