procmail
[Top] [All Lists]

Re: Automatically Deleting Based on Date

1996-10-24 20:36:10

Brock Rozen wrote:
        :0:
        * $ ^From: majordomo$PGHOST
        * ^Subject: (Majordomo results:) .* (who)
        PG/Backup-`date +%m-%d`

I haven't figured out how to have it delete the previous folder
automatically. These messages are received (if everything works out) once
a day. Thus, the previous folder is the day before.

The following may not be pretty, but I believe (knock wood) that it
should work.  The date command is capable of generating a date
/relative/ to today.  So, in order to delete yesterday's folder,
you could simply add the following to your action:
    rm -f PG/Backup-`date -d '-1 day' +'%M-%d'`;
Using the -f option of rm means that the file will be removed without
error -- whether or not it exists, and the date will append the
appropriate suffix to the filename to delete yesterday's file.

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