So I want to schedule a script that is run by a cron job (of sorts) every X hours... with a kicker
Here is what I use to run the posts every X hours, no problem up until this point... the brain twister for me, comes after... I want to be able to input a variable "starting time" and then execute ever X hours AFTER the START TIME.
The idea is to manage multiple posts, each executing on a slightly different schedule.
So,
Post #1, start time, 12:00 (posts ever 2 hours) so, would post at 2:00, 4:00, 6:00 and so on
Post #2, start time, 12:30 (posts ever 2 hours) so, would post at 2:30, 4:30, 6:30 and so on
p.s.
clock looks like:
2013-07-18 3:14
using:
$hour = date("G:i"); $day = date("d"); $month = date("m"); $year = date("Y");
$nextpost = 2; // every 2 hours
$t1 = StrToTime ( "$year-$month-$day $hour" );
$t2 = StrToTime ( "$rowxxx[LASTPOST]" );
$diff = $t1 - $t2;
$hours = $diff / ( 60 * 60 );
echo "Hours past since last post: $hours";
$when = $nextpost - $hours;
echo "<p>Hours until next post " . $when . "</p>";
$SQL = "SELECT * from $table ORDER BY QUED DESC, LASTPOST ASC limit 1";
$result = @mySQL_query( $SQL ); while( $row = @mySQL_fetch_array( $result ) ) {
if($hours > $nextpost)
{
// execute post code
}
thanks for any help!