procmail
[Top] [All Lists]

running a recipe only during certain hours

1999-06-18 17:28:50
Zombie Cow asked,

| Is there a handy way to take into account the time of day in procmail
| scripts?

Absolutely.  It's easiest if the input to procmail has From_ postmarks.
I use this method a lot to make recipes that turn themselves on and off
at preset times and dates (or days of the week).

| I have a friend who would like to get his e-mail (top 200 chars)
| forwarded to his GSM as a text message, and all this is OK and I
| think I can do, but how can I take into account the time of day,
| as he would like this to happen only during 1600-0800 clock and
| not during the business hours.

 :0 # c flag if appropriate
 * ^^From +[^ ].* (Sat |Sun |0[0-7]:|1[6-9]:|2.:)
 * other conditions for paging
 ! pagernumber(_at_)pagercomp(_dot_)any

It doesn't recognize holidays that fall during the week, but doing so would
complicate it greatly, plus I don't know which holidays ZC's friend gets off,
having never lived in Finland.  Era?

If you don't have From_ lines with timestamps, you can extract the time from
the topmost Received: header, or failing all else, you can run date(1).