I'm working on a website which only registered users can access, and they are manually added to the site, since there is no registration enabled. Think of it as a private shop. The number of users is below 1000.

Each of the users can set a couple of events, such as birthday. They usually add less than 10.

I want to inform the user by email about their events, when there is a couple of days remaining to reach that event.

Now the question is, is it performance-wise better to run a single cron job every day at 00:00 and loop through all users and check their events ( stored as metadata ), or should I set a yearly cron job for each event of each user ( which ends up in having a thousand of cron jobs )?

  • 1
    If its preformance I would create a new table for the events and then just need to select all events with the date range and send the email. it will be much faster than getting all users and check their metadata for dates. Anyway single cron can handle the 10k rows easy.
    – Shibi
    Dec 7, 2017 at 14:00

1 Answer 1


Run a single cron, it's much more manageable and more stable, and performance shouldn't be an issue since you do 99% of the work of selecting which user should be notified in MySQL, which will be extremely fast.

I'd use a table to save each day (and each user on that day) that my cron has successfully run for, to make it more resilient. Plan for failure, not for success, because it will fail at some point, and the importance is how bad that failure will be and how much time it will take you to fix the fallout.

Server crashes right before midnight and is rebooted at 00:05? No problem, just run the job manually, or wait till the next day, it'll run two days in one run!

Server crashes while executing the cron? No worries, the next time it runs, it'll pick up right where it stopped last time.

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.