procmail
[Top] [All Lists]

Re: Auto Stop based on time of day

1995-10-18 12:38:46
Alan Stebbens suggested to Abe Philip, who wanted a paging recipe to work
only from 7 AM to 11 PM,

| 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 "mailpage" only if both the subject matches and the
| file test succeeds.  The file test will succeed only between 11pm and 7am.

Most versions of cron grok the $HOME variable, so you don't need to wrap the
cron jobs in a layer of csh just to get the tildes interpreted:

      0 23 * * *        touch $HOME/.mail.relay.on
      0 7 * * * rm -f $HOME/.mail.relay.on

In all honesty, if Abe's system gives usable From_ lines, I like my sugges-
tion better.  I use it all the time to turn blocks of procmail code on and
off at given times or dates, and it works likes a charm.  It uses many fewer
processes and is less likely to get the status wrong if for any reason one of
the cron jobs fails to run or doesn't do its job.

Plus I think you got it inside out: currently you have paging on at night and
off all day.  Abe wanted the opposite.  So I still recommend this:

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

If I misunderstood and Abe wants to be paged only at night (but I'm very sure
he meant NOT at night),

      :0 c
      * ^From .*(fpatna1|vealey).* (0[0-6]|23):[0-5][0-9]:
      | $HOME/bin/mailpage

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