Cronjob or MySQL event?

I would always go a cron job, because:

  • That’s where sysadmins will expect it to be (this point is not to be underestimated)
  • crontab is bullet-proof, time-tested, extremely widely used and understood
  • You can freely direct/analyse error/success messages where you want
  • Some database tasks require/prefer mysql to be off-line (eg full backup), so you’ve got to use cron for those – it’s a bad idea to have some tasks done with cron and some done with mysql; you’ll be unsure where to look
  • You can chain up other events that should follow if you’ve got a shell script

And finally, just because you can do something, doesn’t mean it’s a good idea. Mysql is good at data stuff. Don’t use it for “shell” stuff.

Leave a Comment