Using PHP, I have a query that goes through my DB looking for pending tasks with reminder triggers at certain times of the day. I have a cronjob that runs every 10 mins and chec
I just very recently wrote my own solution to a very similar problem using PHP and MySQL.
Essentially: cron job runs a script at a set interval, that script checks the database for pending jobs, runs them, and deletes the jobs.
This is simply what I needed to do, but it could be modified to work for time intervals.
I wrote a separate PHP script that runs the actual job (a newsletter system) to make this automation a bit more useful. That is, I can run whatever command I want from it, I accomplish this by storing the name of the actual command and its arguments in the automator script.
exec("~/scripts/{$row['command']} {$row['args']}");
allows me to store arguments to the database to make my newsletter script more useful. You use the array $argv to grab the arguments, $argv[0] is the script name the the arguments follow in order.
I store all the newsletter info in a seperate table in the database which sorts them in order chronologically. The other, important, fields are the subject and body of the email. I then simply pass two arguments to newsletter.php to make it do exactly what I want: newsletter number and subscriber number (or all).
Testing for the time (10 minutes before) can be done with something like this (I over simplified for the sake of making it easier to understand):
date_default_timezone_set('America/Denver');
$month=;//without leading zeros
$day=;//without leading zeros
$hour=;//24 hour without leading zeros
$min=;//needs leading zeros
if($month==date(n) and $day==date(j)){
if($hour==date(G)){
if(($min-date(i))<=10){
//run command
}
}elseif(($hour-1)==date(g)){
if(($min-date(i))<=(-50)){
//run command
}
}
}
You will want to change the timezone to your own, and pull the date and time information from the DB in some way.
The second part of the script (to run commands scheduled in the first 9 minutes of an hour) is untested but the first part I quickly tested it just now.
Hope this helps.