procmail
[Top] [All Lists]

Re: Recipes based on date and time

1996-10-29 09:37:05
On Tuesday 29 October 96, at 14 h 0, the keyboard of gilles(_at_)mc2(_dot_)fr 
(Gilles GOULLET) wrote:

      I just want to make some of my recipes being taken in account only
during certain periods, typically at business hours.

date(1) offers a lot of options to retrieve date and time.

      So the recipe "put personal mail in the appropriate folder" would
have to become "put personal mail in appropriate folder if business hours". 

Beware with the following recipes: date and test are likely to have 
different options according to the Unix you use (I use only GNU tools so 
I'm safe and portable).

DAY=`date +'%a'`
HOUR=`date +'%k'`

# Put personal mail in /tmp/personal if business hours
:0
* TO.*some_address
* ? test ( $HOUR -le 17 ) -a ( $HOUR -ge 9 ) \
   -a ( $DAY != "Sat" ) -a ( $DAY != "Sun" )
/tmp/personal

# Put personal mail in another folder otherwise 
:0
* TO.*some_address
/tmp/personal-2

# Let everything else goes where it belongs


      I can figure how to do this using crontab to set up a flag file and
making procmail test the presence of this flag, but do you procmail gurus
have a more convenient way to achieve this ?

I think your solution is simpler and it has one advantage: you can set 
and remove the flag file by hand if necessary.

:0
* TO.*some_address
* ? test -e /tmp/business
/tmp/personal

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