Configuring IRIS: Cron Expresion for DELETE and ARCHIVE
Understanding Cron Intervals
This section explains how cron intervals work. Cron intervals allow scheduling of maintenance tasks at specific times and intervals. For example:
- "*/1 * * * *" – This runs the task every minute.
- "0 1 * * *" – This runs the task daily at 1:00 AM.
Why You Cannot Use All 3 Methods Simultaneously
It is not logical to use the DELETE, ARCHIVE, and DELETEARCHIVE methods at the same time. Each method serves a distinct purpose:
DELETE Method
The DELETE method is responsible for removing completed tasks from the system. Specifically, for the IRIS system (used for sending emails), DELETE will:
- Delete the successfully sent email from the SQL table.
- Delete the file that was attached to the email.
- Delete the HTML file used as the body of the email.
ARCHIVE Method
The ARCHIVE method moves successfully completed tasks to an archive location. In the IRIS system, this method will:
- Move the email record from the SQL table to an archive table.
- Move the attached file to an archive directory.
- Move the HTML email body file to the archive.
"ArchiveFilesPath": "C:/kuku/IrisArchive",
"MessageArchiveTableName": "Messages_Clone",
"ParametersArchiveTableName": "Parameters_Clone",
"AttachmentsArchiveTableName": "Attachments_Clone"
DELETEARCHIVE Method
The DELETEARCHIVE method is responsible for cleaning up the archive itself after a set period. It will:
- Delete old files from the archive folder.
- Remove data from the archived tables (Messages_Clone, Parameters_Clone, Attachments_Clone).
"ArchiveFilesPath": "C:/kuku/IrisArchive",
"MessageArchiveTableName": "Messages_Clone",
"ParametersArchiveTableName": "Parameters_Clone",
"AttachmentsArchiveTableName": "Attachments_Clone"
Real-World Example: Email System Maintenance (IRIS)
In the IRIS email system, the following tasks are performed:
- The DELETE method removes all successfully sent emails, their attachments, and HTML bodies.
- The ARCHIVE method moves these items to an archive folder and stores them in a cloned SQL table for future reference.
- The DELETEARCHIVE method periodically cleans up the archived files and data after 60 days.
Modifying Cron Intervals in JSON
In the maintenance configuration, you can modify the "Interval" value to control how often tasks are executed. Here’s an example:
"Interval": "1 * * * *",
"PreservationInMinutes": 1
The "Interval" value follows the cron syntax, where each position represents a different unit of time. Here's how the breakdown works:
* * * * *
| | | | |
| | | | ----- Day of the week (0 - Sunday, 6 - Saturday)
| | | ------- Month (1 - January, 12 - December)
| | --------- Day of the month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
For example, the interval "*/5 * * * *" runs the task every 5 minutes, and "0 0 * * *" runs it daily at midnight.
To change the interval so that the task runs every 10 minutes, modify the value to:
"Interval": "*/10 * * * *"
The "PreservationInMinutes" value defines how long the task results are kept. In the example, "PreservationInMinutes": 1 keeps the results for only 1 minute. You can increase this value to change the retention period.