procmail
[Top] [All Lists]

Re: Auto Stop based on time of day

1995-10-17 11:37:53
Abe Philip asked,

| I have a [recipe] which executes an external program. The problem is that 
| it executes whenever I get mail which includes the middle of the night. 
| Is it possible to stop execution of the [recipe] based on the time of day?

Yes.

| This is the [recipe] I'm using:
| 
| :0 c
| *^From.*(fpatna1|vealey)
| | $HOME/bin/mailpage
| 
| I guess I'm looking for some sort of condition to check the current time 
| and if its outside of the hours 11pm and 7am then execute the action. Can 
| anyone give me some pointers?

How do your From_ lines look?  If they're the traditional kind that sendmail
and smail add, they include the local time on your system at receipt.  So
include a check that the hour is between 07 and 22 inclusive, like this:

  :0 c
  *^From .*(fpatna1|vealey).* (0[789]|1.|2[012]):[0-5][0-9]:
  | $HOME/bin/mailpage

I included the minutes and the colon that separates the minutes from the
seconds so that the expression for testing the 07-22 range can match only
on the hour.

<Prev in Thread] Current Thread [Next in Thread>