Basically I'm designing an alert system in PHP with CodeIgniter. I want the alerts to be "scheduled" by inserting a database row and then sent out in batches periodically. The alerts are sent out via email.
The only way I can think to achieve this is to require a cron script to call a CLI-only controller every minute or so that checks for scheduled alerts and sends them if it finds anything.
Something is telling me that having a cron script run so often is poorly designed but I can't think of any other way to do it.
Advice?
Making the alerts asynchronous By separating the alert task from the rest of the code is desirable.
I don't see a problem with a cron script , I would ask why do you need to do it so often? Setting a threshold is a good idea , but you would still need to check at the end of day or whenever to make sure it has fired anyway.
You could rather then use the whole overhead of controller (and rest of framework to get there) - maybe just make a lightweight CLI php script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With