Execute a task at any given time

2

I am developing a system of deadlines and alerts. The user will register a deadline, date and time of the term and define if he wants to receive the alert with 1, 2 or 3 hours in advance.

How can I perform a function that checks and is it time to send the email to the user? I did not want to do a CRON to run every minute and check if it's time to send the email.

There is some way to create an automatic CRON so that it runs only at the time of sending the email to the user.

    
asked by anonymous 08.08.2018 / 14:43

1 answer

0

I believe that making CRON run every minute (or the minimum of multiple minutes your schedule allows) will not be a problem, since the job will only check and only actually do the job if you need to. Optimize this task to check and return quickly if there is a failure that everything is at home.

Do not forget to check if you will want to overlap or not. Overlap is when a job takes too long to execute and the next minute arrives firing a next job in parallel. You may want this or not.

Remember to always go by the simplest path that works (every project has its context), leave it to do super optimizations only if you have verified performance problems.

    
08.08.2018 / 15:23