1

I need to run a codeigniter job once everyday, I need to check my mysql db in order to see if there is an scheduled email task for that day, if there is one, send the emails for that service; previously, that service was made manually, there, what we used to do was to create an uri with the proper parameters and submit it via a browser, like this:

http://www.ourdomain.edu/ci/controller/method/1/49/7

where the 1, the 49 and the 7 are dynamic parameters, the 1 is a status parameter that might change, the 49 is the id that belongs to that service and only to it (no other service has that id, and it changes from an email service to the next) and the 7 indicates the size of the batch to send (per email account serving the emails), what I can do now is to echo the uri for command line use for each case:

controller method 1 dynamic_id_to_use 7

so, it would be easy to create the full command for console use like this:

$: php index.php controller method 1 dynamic_id_to_use 7

but this is not what I need to do, what I need to do is to execute a cron job that checks for scheduled job for that day, read its parameters and process them (I can do that right now), if there is at least one, run a script or codeigniter job that executes the line command php index.php controller method 1 dynamic_id_to_use 7, The services can be scheduled by the users whenever they need it to, so, that´s why consecutive services and their id´s are not necessarily consecutive, thank you in advance for your assistance.

1 Answer 1

2

Let's do one thing make a new table with 5 columns

Cron_table
-----------
Id
status
Dynamic Id
Batch size
Cron-status

Now store all your cron details to this table as per your requirements and set cront-status to zero. Now make a cron for this to take data with cron-status =0 and after getting results process the work you want to after work done set cron-status = 1.

Let me know if this helps you or not.

Enjoy coding ...

3
  • So, you are proposing a table like this? [Cron_table Id | status | Dynamic Id | Batch size | Cron-status] am I right? Get it now, Cron_table is your table, Id is its 1st column, aren´t status and Cron-status redundant? Dec 10, 2014 at 18:59
  • Now I get you fully, the 1st status makes reference to my 1st parameter, thanks!! Dec 10, 2014 at 19:16
  • yes cron_table is table name and id is auto increment, status is the first parameter of the url (current cron describe above), dynamic_id (second parameter), batch_size (thrid parameter) and cron_status
    – Rana Soyab
    Dec 11, 2014 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.