procmail
[Top] [All Lists]

Re: Auto Stop based on time of day

1995-10-17 18:08:23
I have a receipe 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 receipe based on the time of day?

This is the receipe 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?

Put something like the following entries in your personal crontab for
your userid (and not knowing if you particular cron "cd's" to your home
directory first):

    0 23 * * *  /bin/csh -c 'touch ~aphili1/.mail.relay.on'
    0 7 * * *   /bi/csh -c 'rm -f ~aphili1/.mail.relay.on'

Then, in your .procmailrc do:

    :0 c
    * ^From.*(fpatna1|vealey)
    * test -f $HOME/.mail.relay.on
    | $HOME/bin/mailpage

the script will only "mailpage" only if both the subject matches and the
file test succeeds.  The file test will succeed only between 11pm and 7am.

Alan

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