The best thing to do would be a one cron job that would hourly, and compares the dates of each job against the mailing times.
The cron entry is (run once a hour on the hour)
0 * * * * sendjobwarnings
Then something like, psuedocode, change to match your favourite
scripting language, and database protocols.
now = timenow();
foreach job in database {
expiretime = dblookup("select expiretime from table where jobid="+job+";");
user = dblookup("select username from table where jobid="+job+";");
if ( (expiretime-now)<0 and (expiretime-now)>-onehour){ emailuser_jobexpiredmessage; }
if (expiretime-now)<7days && (expire-now)>7days-onehour){
emailuser_jobtoexpirein7daysmessage; }
}
... 14 days 3 days etc
}
Hope this help
PHP Programming Feed @ Feed Distiller
|