0

I am running a simple mysql db that contatins values for temperature sensors in a clients home. I have been looking into different ways to create email alerting if the temp is below or above a preset value.

There are ways that I can accomplish this via a simple php script to be ran off of a cron job from what i have gathered but the problem with them is it needs to be put 'on hold' for a certain amount of time that way once a client gets an alert they wont keep getting that alert every five minutes when the cron runs.

Also as a future question of this project, is there a way to have cron jobs created from values that users store in the sql db? That way the users can have customized alerting?

Sorry if it didn't come out clear, I will be right next to the computer all day to answer questions on this regard if need be.

user1707616
  • 117
  • 2
  • 9

1 Answers1

1

To resolve your problem, create an alerts table that keeps track of when the last alert was. Depending on your platform, it may be possible for PHP to schedule cron jobs. You could save the user settings in a table and have PHP create/update/delete the cron jobs.

Community
  • 1
  • 1
Kermit
  • 32,563
  • 10
  • 80
  • 117
  • So the alerting table would simply have the last time an alert was triggerd for that account and a value say 1. Then have a script that says if timestamp > xamount of time then run this alerting query again? – user1707616 Jan 28 '13 at 15:53
  • 1
    You don't need a value; you just need a stamp (`datetime`) of the last alert. – Kermit Jan 28 '13 at 15:54
  • Holy wow that was quick. I just hit the enter key on accident when trying to shift enter. But alright i see how you could simply do that and it solves a good bit of my problem with this. I will look into the custom php cron jobs later. The end result will be user customized alerting for a simple sql db and I think I can do that with what you have told me. – user1707616 Jan 28 '13 at 15:56