in reply to Email Thresholding

Store the last time an email was sent as the create/modification date of a file (or as data within the file). Check the time elapsed every time you want to send another email.

if ($condition_requires_email) { if (-e 'last.email' && -M 'last.email' < 1.0/24.0) { print "Don't need to send email yet\n"; } else { &send_email(); system('touch','last.email'); } }

Update: corrected logic error pointed out by jhourcle.

Dum Spiro Spero

Replies are listed 'Best First'.
Re^2: Email Thresholding
by jhourcle (Prior) on Apr 05, 2015 at 05:38 UTC

    Although the log-checking process would work, this one is likely the fastest solution for most situations.

    ... although I'd move the $condition_requires_email to an outer if block that wraps the whole thing ... otherwise, your logic would send e-mail when (!$condition_requires_email)

    I don't know what type of NRT data bfdi533 is dealing with, but with the space weather data that I deal with, getting the alerts out without a potential 1 hr delay is quite important. (and contractually required, according to the mission's PDMP (Project Data Management Plan)).