55 Configuring Message Expiration (Tasks)

This information describes the tasks you use to expire messages. See "Message Store Message Expiration" for overview and conceptual information.

Topics:

To Set imexpire Rules Textually

Note:

In Unified Configuration, you can continue to configure messaging expiration as explained in this information, or use the msconfig command to individually set the appropriate configuration options. Modifying the store.expirerule file enables access to more functionality than using the msconfig command.

You expire messages by specifying rules in a store.expirerule file. The store.expirerule file contains one expire criteria per line. An expire criteria of the global rule configuration file MessagingServer_home/config/store.expirerule has the following format:

<rule_name>.<attribute>: <value>

An expiration rule for a user or mailbox rule configuration file has the following format:

<attribute>: <value>

The following example shows a set of global expiration rules in the MessagingServer_home/config/store.expirerule file.

Example imexpire Rules

Rule1.regexp: 1
Rule1.folderpattern: user/.*
Rule1.messagesize: 100000
Rule1.messagesizedays: 3
Rule1.deleted: or
Rule1.messageheader.Subject: Vigara Now!
Rule1.messageheader.Subject: XXX Porn!
Rule1.messagecount: 1000
Rule1.messagedays: 365
Rule2.regexp: 1
Rule2.folderpattern: user/.*@example.org/.*
Rule2.exclusive: 1
Rule2.deleted: or
Rule2.messagedays: 14
Rule2.messagecount: 1000
Rule3.folderpattern: user/f.dostoevski/inbox
Rule3.messageheader.subject: On-line Casino

Rule 1 sets the global expiration policy (that is, policy that applies to all messages) to:

  • Enable UNIX regular expressions in rules creation.

  • Remove messages larger than 100,000 bytes after 3 days.

  • Remove messages deleted by the user.

  • Remove any message with the strings "Vigara Now!" or "XXX Porn!" in the Subject: header.

  • Limit all folders to 1,000 messages. After 1,000 messages, the system removes the oldest messages on a folder to keep the total to 1,000.

  • Remove all messages older than 365 days.

Rule 2 sets the message expiration policy for users at the hosted domain example.org. It limits mailbox sizes to 1 megabyte, removes messages that have been deleted, and removes messages older than 14 days.

Rule 3 sets the message expiration policy for messages in the inbox folder of user f.dostoevski. It removes messages with a subject line having the expression "On-line Casino."

Note that headers other than Subject: can be used.

To Set Expiration Rules by Using the msconfig Command

  • In Unified Configuration, you can set expiration rules by using the following msconfig command:

    msconfig set expirerule:<name>.<option> <value>
    

    For example:

    msconfig set expirerule:Rule1.folderpattern user/.*
    ./msconfig set expirerule:Rule1.messagesize 100000
    .msconfig set expirerule:Rule1.messagesizedays 3
    

You can set the following options in this way:

  • deleted

  • exclusive

  • folderpattern

  • foldersizebytes

  • messagecount

  • messagedays

  • messagesize

  • messagesizedays

  • seen

To Set imexpire Folder Patterns

Folder patterns can be specified by using POSIX regular expressions by setting the imexpire attribute regex to 1. If not specified, IMAP expressions are used. The format must start with a user/ followed by a pattern. Table 55-1 shows the folder pattern for various folders.

Table 55-1 imexpire Folder Patterns Using Regular Expressions

Scope Folder Pattern (regex=0) Folder Pattern (regex=1)

Apply rule to all messages in all folders of userid.

user/userid/*

user/userid/.*

Apply rule to messages of userid in folder Sent:.

user/userid/Sent

user/userid/Sent

Apply rule to entire message store.

user/*

user/.*

Apply rule to any folder called Trash anywhere in any user's hierarchy.

user/*/Trash

user/.*/Trash

Apply rule to folders in hosted domain example.org.

user/*@example.org/*

user/.*@example.org/.*

Apply rule to folders in default domain.

Not applicable

user/[Configuring Message Expiration in Unified Configuration (Tasks)^@]*/.*


To Schedule Message Expiration and Logging Level

You activate message expiration by using the imsched scheduling daemon. By default, imsched invokes imexpire at 23:00 every day. Use the "impurge" command for the purge function. The imexpire schedule can be customized by setting the schedule.task:expire.crontab option as described in "Expire and Purge Log and Scheduling Options."

Expire and purge can take a long time to complete on a large message store. You should experiment and decide how often to run these processes. For example, if an expire and purge cycle takes 10 hours, you might not want the default schedule of running expire and purge once a day. Schedule expire and purge by using the imexpire command and the automatic task scheduling option (see "Scheduling Automatic Tasks"). For example:

msconfig
msconfig> set schedule.task:expire.crontab "0 1 * * 6 bin/imexpire -e"
msconfig# write
msconfig> exit

In this example, messages are expired at 1 AM Saturdays and purged every night at 11 PM. If no purge schedule is set, imexpire performs purge after an expire.

Expire and Purge Log and Scheduling Options

For Purge options, see "Maintenance Queue Configuration Options." Clicking on the specific option will often provide both the legacy (configutil) parameter and the Unified Configuration (msconfig) option.

Table 55-2 Expire and Purge Log and Scheduling Options

Option Description

schedule.task:expire.enable

Whether the expire task should be scheduled. Default: 1

schedule.task:expire.crontab

Interval for running imexpire. Uses UNIX crontab format: minute hour day-of-month month-of-year day-of-week

The values are separated by a space or tab and can be 0-59, 0-23, 1-31, 1-12 and 0-6 (with 0=Sunday) respectively. Each time field can be either an asterisk (meaning all legal values), a list of comma-separated values, or a range of two values separated by a hyphen. Note that days can be specified by both day of the month and day of the week, however, it is not typical to use them both since the number of such occurrences are very small. If they are both specified, then both will be required. For example, setting the 17th day of the month and Tuesday will require both values to be true.

You can also use the -e and -c flags with imexpire to and expire only or purge only respectively. See "imexpire."

Interval Examples:

  1. Run imexpire at 12:30am, 8:30am, and 4:30pm:30 0,8,16 * * * bin/imexpire

  2. Run imexpire at weekday morning at 3:15 am:15 3 * * 1-5 bin/imexpire

  3. Run imexpire only on Mondays:0 0 * * 1 bin/imexpire Default: 0 23 * * * bin/imexpire

    To disable: Run msconfig set schedule.task:expire.enable 0

store.expire.exploglevel

Specify a log level:

0 = No log.

1 = Log summary for the entire expire session.

2 = Log one message per mailbox expired.

3 = Log one message per message expired.

Default: 0


To Set imexpire Logging Levels

imexpire logs a summary to the default log file upon completion. If expire is invoked from the command line, the -v (verbose) and -d (debug) options can be used to instruct imexpire to log detail status and debug messages to stderr. If imexpire is invoked by imsched, the configuration option store.expire.exploglevel can be set to 0, 1, 2, or 3 for different levels of logging. Loglevel 0 is the default, and no logging is performed. Loglevel 1 logs a summary for the entire expire session. Loglevel 2 logs one message per mailbox expired. Loglevel 3 logs one message per message expired.

The following example invokes expire from the command line to set verbose logging and shows the resulting messages in the default log file, MessagingServer_home/log/default.

cd /opt/sun/comms/messaging64/bin
imexpire -n -v 1
tail ../log/default
[25/Nov/2010:11:51:51 +1100] server imexpire[20730]: General Notice: imexpire started
[25/Nov/2010:11:51:51 +1100] server imexpire[20730]: General Notice: iBiff plugin loaded: ms-internal
[25/Nov/2010:11:51:51 +1100] server imexpire[20730]: General Notice: primary partition: expired 0 messages
[25/Nov/2010:11:51:51 +1100] server imexpire[20730]: General Notice: Expired 0 messages
[25/Nov/2010:11:51:51 +1100] server imexpire[20730]: General Notice: Expire finished

To Exclude Specified Users from Message Expiration

Exclude specified users from the expire rules by adding their user ID, one per line, in a file called expire_exclude_list in the MessagingServer_home/config directory. Or, configure a "dummy" exclusive expire rule under the user's mailbox.