Delete Attachments

This feature enables the automatic deletion of ticket attachments that were closed in a definable time span. Furthermore, file types can be defined as additional filter criteria.

Note

This feature is only available to On-Premise customers. If you are a Managed customer, this feature is taken care of by the Customer Solutions Team in OTRS. Please contact us via support@otrs.com or in the OTRS Portal.

Enable Attachment Deletion

This feature is not enabled by default, it must be configured by an administrator first.

To use this feature:

  1. Go to the System Configuration screen.

  2. Search for the setting OTRSDeleteAttachments::Filetypes and add some file MIME types as key-value pairs. The key is the MIME type, the value is the deletion flag.

    • 0: This type of attachments are not to be deleted.

    • 1: This type of attachments are going to deleted.

File Types Setting

File Types Setting

Automatic File Type Population

There is a console command Maint::Ticket::Attachment::AddMIMETypes to populate the system configuration setting automatically.

otrs> /opt/otrs/bin/otrs.Console.pl Maint::Ticket::Attachment::AddMIMETypes
Searching attachment types received the last 90 days...
|       Added undefined MIME type: application/x-yaml
|       Added undefined MIME type: image/png
|       Added undefined MIME type: text/html
|       Added undefined MIME type: application/pdf
|       Added undefined MIME type: text/plain
Updating SysConfig...
Done.

The console command collects MIME types of attachments, that are in closed tickets and received within the last 90 days. Use the --all option to iterate over all closed tickets.

See also

Run the command with the --help option to see the possibilities.

otrs> bin/otrs.Console.pl Maint::Ticket::Attachment::AddMIMETypes --help

Delete Attachments From Tickets

The attachment deletion is done by console command Maint::Ticket::Attachment::Delete. Check the following settings to customize the job:

OTRSDeleteAttachments::Queues

A list of queues (specified by their names) which are processed by the Maint::Ticket::Attachment::Delete console command.

Warning

If no queues are defined, all queues will be affected.

OTRSDeleteAttachments::TimeSpan

The starting time (in days) from the current date from which the tickets should be analyzed for deletion.

OTRSDeleteAttachments::TimePeriod

The end time (in days) from the current date up to which the tickets should be analyzed for deletion.

Example:

TimeSpan: 10
TimePeriod: 40
                           Eligible  tickets
              |=========================================|
                                                        |=============|
                            TimePeriod (40)              TimeSpan (10)
|-------------|-------------|-------------|-------------|-------------|
50 days ago   40 days ago   30 days ago   20 days ago   10 days ago   Today
                                                        |
                                                       \ /
                                                Ticket close time

Means that all tickets between 10 days ago from the current date and 40 days ago from the current date are analyzed for deletion.

The value of TimePeriod must be always higher than the value of TimeSpan.

See also

Run the command with the --help option to see the possibilities.

otrs> bin/otrs.Console.pl Maint::Ticket::Attachment::Delete --help

Delete Attachments Automatically

Updating the file types and deleting the attachments can be run in the background by the OTRS daemon. Enable the following settings to run the jobs in a regular basis:

Daemon::SchedulerCronTaskManager::Task###OTRSDeleteAttachments

Delete attachments from tickets.

Daemon::SchedulerCronTaskManager::Task###OTRSDeleteAttachments_AddMIMETypes

Populate system configuration MIME types for attachment deletion.

Note

Do not forget to restart the OTRS daemon after the system configuration is changed.

Scroll to Top