# Tasks

As an administrator, you may schedule and execute maintenance tasks to automate repository management. Users with the `nexus-tasks` privilege may access this configuration.

## View Tasks

The tasks table shows the following columns:

- **Name** \- A user-defined name to identify it in the user interface and log files.
- **Type** \- The list of available task types is documented in more detail below.
- **Status** \- Displays when a task is disabled, waiting for its next run, running, or the progress of the current run.
- **Schedule** \- Displays when the task is configured to run.
- **Next run** \- The date and time of the next execution are based on the schedule.
- **Last run and Last result** \- The result of the last execution.

## Configure Tasks

Add new tasks by selecting "Create task " or edit existing ones. Custom fields are displayed for each task depending on the task type.

When creating or updating a scheduled task, configure the following default properties:

- **Task enabled** \- Enable or disable the task
- **Notification Email** \- Configure a notification email for the task execution
- **Notification Condition** \- Send on Failure or either Success or Failure
- **Task frequency** \- Configure the schedule for the task executions.

```
Manual, Once, Hourly, Daily, Weekly, Monthly, and Advanced
```

Advanced (provide a CRON expression) follows the UNIX-style CRON syntax

### Advanced task frequency configuration

```
The characters are not case-sensitive. "LW" may be combined for the "last weekday of the month".
[seconds] [minutes] [hours] [day-of-month] [month] [day-of-week] [year]

* - any value; * in the minute field triggers every minute
? - allowed for the day-of-month and day-of-week fields for no specific value
- - to specify a range such as 10-12 for every hour in the range
, - to specify one than one value such as [MON,WED,FRI] in the day-of-week
/ - specify a start value and increment such as "0/15" for every 15 seconds
L - short-hand for the last value in a named range; common in the last day of the week or month
W - for a specific weekday of the month adjusted for the nearest weekday
# - specify "the nth" named day of the month; "6#3" for the third Friday(6) of the month

EXAMPLES
0 0 12 * * ?              ||  12pm (noon)
0 15 10 ? * *             ||  10:15am
0  * 14 * * ?             ||  Every minute between 2-3pm
0 0/5 14 * * ?            ||  Every 5 minutes between 2-3pm
0 0/5 14,18 * * ?         ||  Every 5 minutes between 2-3pm and 6-7pm
0 0-5 14 * * ?            ||  Every minute starting at 2pm and ending at 2:05pm, every day
0 10,44 14 ? 3 WED        ||  2:10pm and at 2:44pm every Wednesday in the month of March
0 15 10 ? * MON-FRI       ||  10:15am every Monday through Friday
0 15 10 15 * ?            ||  10:15am on the 15th day of the month
0 15 10 L * ?             ||  10:15am on the last day of the month
0 15 10 ? * 6L            ||  10:15am on the last Friday of every month
0 15 10 ? * 6#3           ||  10:15am on the third Friday of the month
```

## Task Logs

The output of every task run go to a separate log file that is configured to be removed after 30 days. These task logs are stored in the following task directory:

```
$data-dir/log/tasks
```

The file name of each task log is the task type followed by the date and time the task started. For example:

```
repository-maven.purge-unused-snapshots-20170618153235.log
```

The output of the task goes to the `nexus.log` and the specific task log. Some tasks only go to the `nexus.log`.

For long-running tasks, progress such as the number of items is logged to the `nexus.log` every 10 minutes.

## Types of Tasks

Tasks are prefixed to fall into the following category types:

- #### Admin

Tasks that include regular maintenance such as backing up the database and cleaning up artifacts through cleanup policies. These tasks are often scheduled to run regularly.

- #### Formats

Format-specific tasks are typically to repair metadata and indexes. Some tasks are used for format-specific cleanup tasks which are scheduled regularly.

- #### Repair

Tasks with the "`Repair`" prefix are only intended to be run manually when encountering specific issues with your system.

**Note**

Sonatype recommends running the `Repair` tasks only at the advice of a Sonatype staff member.

- #### Repository

These tasks provide specific functionality such as import/export but include replication and some management tasks. These tasks may be scheduled depending on your use case. Here are some outliers:

```
Admin - Change repository blob store
Admin - Remove a member from a blob store group
Admin - Log database table record counts
```

- #### Statistics

These tasks are for updating useful metrics available in the Repository user interface.

| Task Name / ID | Description |
| --- | --- |
| ### Admin - Backup H2 Database<br>h2.backup.task | Performs a full backup of the underlying config, security, and component databases when using the embedded H2 database. The task adds a timestamp to the backup files in the backup data location.<br>Choose a location for the backup data for this task. Schedule the task to run as required by your maintenance policy. This task does not back up the contents of the blob stores, only the database. |
| ### Admin - Export databases for backup<br>db.backup | Performs a backup of the internal legacy OrientDB database and its underlying config, security, and component databases. Choose a safe location for the backed-up data. The task adds a timestamp to the backup files in the backup data location.<br>This task does not back up the repository content and temporarily puts the repository into a read-only state |
| ### Admin - Cleanup repositories using their associated policies<br>repository.cleanup | Deletes components based on your cleanup policies. The task is automatically created on server restart and is scheduled to run daily at 1 am server time. You may disable or reschedule the task.<br>See [Cleanup Policies](https://help.sonatype.com/en/cleanup-policies.html "Cleanup Policies") for more information. |
| ### Admin - Cleanup Tags<br>tags.cleanup | Remove tags and associated components based on your maintenance criteria.<br>See [Tagging](https://help.sonatype.com/en/tagging.html#cleanup-task "Cleanup Task") for details. |
| ### Admin - Cleanup unused asset blobs<br>assetBlob.cleanup | This task soft-deletes unused blobs to prevent Nexus Repository from accidentally creating multiple blobs associated with the same asset. Nexus Repository creates one copy of the task for each format to run every 30 minutes. Use the delay minute/hour property to configure the interval before an asset is soft-deleted. This delay avoids soft-delete files that take a significant amount of time to upload to the repository.<br>```<br>nexus.assetBlobCleanupTask.blobCreatedDelayHour=1<br>nexus.assetBlobCleanupTask.blobCreatedDelayMinute=60<br>```<br>Before version 3.62.0, this task deletes asset records from the related table regardless of the blob created time.<br>This task requires an H2 or PostgreSQL database. |
| ### Admin - Compact blob store<br>blobstore.compact | When components are deleted they are labeled as soft deleted. This task permanently removed soft-deleted files to recover storage space. This task does not apply to some object stores, which use their managed lifecycles.<br>See [Cleanup Policies](https://help.sonatype.com/en/cleanup-policies.html "Cleanup Policies") for more information. |
| ### Admin - Delete orphaned API keys<br>security.purge-api-keys | This task deletes unused API keys generated when using user tokens. Keys are orphaned when the user account is deleted. |
| ### Admin - Log database table record counts<br>cluster.periodicLogging | This task logs clustered database record counts for each node. The task is automatically added when clustering is enabled and can be disabled by including an additional property in the nexus.properties file:<br>```<br>nexus.log.cluster.enabled=false<br>``` |
| ### Admin - Change repository blob store<br>repository.move | Use to change which blob store a repository stores it's components. This task requires H2 or PostgreSQL database.<br>See [Change repository blob store](https://help.sonatype.com/en/change-repository-blob-store.html "Change Repository Blob Store") for more details. |
| ### Admin - Delete blobstore temporary files<br>blobstore.delete-temp-files | Deletes the temporary files a the blob store's temp directory. Only file blob stores are processed. |
| ### Admin - Execute script<br>script | Privously in Nexus Repository, scripts written in Groovy could executed in the tasks menu. These scripts used the APIs to perform maintenance and other modifications. To reduce security risk, as of version 3.21.2 this task is disabled.<br>See the documentation for the [Script API](https://help.sonatype.com/en/script-api.html "Script API"). |
| ### Admin - Export SQL database to script<br>database.export.script.h2.task | This task only exists in release 3.69.0 and is only necessary for deployments already using an H2 database.<br>See [Upgrade H2](https://help.sonatype.com/en/upgrade-h2.html "Upgrading an H2 Database from 1.x to 2.x") for details. |
| ### Admin - Remove a member from a blob store group<br>blobstore.group.memberRemoval | This task removes a blob store from a group. Each blob within the removed store is written back to the group and deleted from the removed blob store.<br>See [Removing a Blob Store from a Group](https://help.sonatype.com/en/blob-stores.html#removing-a-blob-store-from-a-group "Removing a Blob Store from a Group") |
| ### Automatic Malware Management<br>malware.remediator | Requires Repository Firewall<br>This task identifies the malware reported in the malware risk banner found in your proxy repositories.<br>For smaller deployments, selecting all repositories when running the task is recommended. For large deployments, consider setting up individual instances of the tasks for your largest proxy repositories. Run the task no more than once every 24 hours. |
| ### Apt - Rebuild Apt metadata<br>repository.apt.rebuild.metadata | This task rebuilds the metadata for a chosen Apt-hosted repository. |
| ### Docker - Delete incomplete uploads<br>repository.docker.upload-purge | This task cleans up orphaned files that may exist in temporary storage as a result of a restart or incomplete/interrupted uploads.<br>The _Age in Hours_ parameter allows you to configure the minimum age of incomplete uploads to be deleted. |
| ### Docker - Delete unused manifests and images<br>repository.docker.gc | This task deletes Docker tags, manifests, and layers (blobs) that are no longer referenced by any tags or manifests.<br>**Warning**<br>This task deletes manifests and layers if they are pulled or pushed by the Docker digest (for example, `docker pull python@sha256:88236…` instead of `docker pull python:3.9`) because those are not referenced by any tag.<br>In hosted repositories, this data loss is irreversible. To prevent images from being deleted by the _Docker - Delete unused manifests and images_ task, ensure that images are referenced by at least one tag. If an image was pushed by digest and must be retained, **it should be re-tagged and pushed to a repository to maintain a stable reference**. |
| ### Helm - Rebuild Helm metadata<br>repository.helm.rebuild.metadata | Rebuilds the metadata for a chosen Helm-hosted repository. |
| ### Maven - Delete SNAPSHOT<br>repository.maven.remove-snapshots | Deletes SNAPSHOT components from a Maven repository based on a configured number of SNAPSHOTs, age, and release version.<br>See [Maven SNAPSHOT Tasks](https://help.sonatype.com/en/maven-snapshot-tasks.html "Maven SNAPSHOT Tasks") for information. |
| ### Maven - Delete unused SNAPSHOT<br>repository.maven.purge-unused-snapshots | This task has been replaced with the [Cleanup Policies](https://help.sonatype.com/en/cleanup-policies.html "Cleanup Policies") feature.<br>Deletes SNAPSHOT components from a Maven repository based on the number of days it has been since the component was last requested.<br>See [Maven SNAPSHOT Tasks](https://help.sonatype.com/en/maven-snapshot-tasks.html "Maven SNAPSHOT Tasks") for information. |
| ### Maven - Publish Maven Indexer files<br>repository.maven.publish-dotindex | The task publishes the indexer files for all or a specific Maven repository. |
| ### Maven - Unpublish Maven Indexer files<br>repository.maven.unpublish-dotindex | This task is the counterpart to the task _Maven - Publish Maven Indexer_ files and can remove the indexer files. |
| ### Repair - Rebuild Maven repository metadata (maven-metadata.xml)<br>repository.maven.rebuild-metadata | Rebuilds `maven-metadata.xml` files while validating checksums (.md5/.sha1) in the maven-hosted repository. The parameters filter the components that are repaired.<br>The `maven-metadata.xml` files are maintained by the deploying clients. Only run manually to repair a corrupted repository. |
| ### Repair - Repository trim browse tree | Manually trims empty browse nodes from repository browse tree. Can be run against a selected repository only. Intended for large PostgreSQL deployments where automatic browse trimming is disabled, enabling on-demand cleanup without automatic trimming. |
| ### PyPI - Delete index Asset MD5 Metadata<br>repository.pypi.rebuild-metadata | Deletes index assets with MD5 checksums on their links from PyPI repositories. Only removes the index and not the checksum. |
| ### PyPI - Delete legacy proxy assets<br>repository.pypi.delete-legacy-proxy-assets | This task deletes old assets that were previously duplicated due to a code-path change. |
| ### PyPI - Generate Missing SHA256 Checksums<br>repository.pypi.generate-missing-sha256-checksums | Generate sha256 checksums when missing from PyPI metadata. |
| ### Repair - Data Repair Plan<br>blobstore.planReconciliation<br>### Repair - Execute Data Repair Plan<br>blobstore.executeReconciliationPlan | **Do not use this task during normal operation of the server.**<br>See [Data Repair Tasks](https://help.sonatype.com/en/verify-and-repair-data-consistency-tasks.html "Data Repair Tasks") |
| ### Repair - Rebuild repository browse<br>create.browse.nodes | Rebuild the tree browsing data from the database. |
| ### Repair - Rebuild repository search<br>repository.rebuild-index | With support for hosted and proxy repositories, this task rebuilds the search index. It inspects actual components and assets found in the selected repository and thus reflects the true content for supporting search and browse actions.<br>Canceling this task results in a partially rebuilt search index. |
| ### Repair - Recalculate blob store storage<br>blobstore.metrics.reconcile | This is a slow-running task used to fix incorrect blob storage sizes that should be used with care.<br>See [recalculated blob storage performance testing](https://help.sonatype.com/en/recalculate-blob-store-storage-performance-testing.html "Recalculate Blob Store Storage Task Performance Testing") for details. |
| ### Repair - Reconcile component database from blob store<br>blobstore.rebuildComponentDB | **Do not use this task during normal operation of the server.**<br>Use this task to recover lost component metadata from a blob store when restoring content from backup and the database and blob storage are out of sync.<br>See the topic Reconcile Component Database task below. |
| ### Repair - Reconcile date metadata from blob store<br>rebuild.asset.uploadMetadata | Do not run this task except when Nexus Repository version 3.2.1 OR earlier was used and has been upgraded. This task was used to update files when they were missing the creation date. |
| ### Repair - Reconcile npm /-/v1/searchmetadata<br>repository.npm.reindex | Extracts the search metadata from npm packages in npm-hosted repositories to support the '`v1`' search endpoint that replaced the '`all`' endpoint. |
| ### Repair - Rebuild npm metadata<br>repository.npm.rebuild-metadata | Rebuilds the metadata for an npm-hosted repository. Configure the task to rebuild metadata for all packages or a specified package. This task may be used to repair when the npm metadata has been corrupted. |
| #### Repair - Rebuild NuGet symbol index<br>nuget.symbol.reindex | Indexes existing symbol packages (`.snupkg` files) in a NuGet hosted repository into the symbol server index. Use this task to enable symbol server functionality for packages uploaded before symbol server support was enabled, or to rebuild the symbol index after data inconsistency. |
| ### Repair - Rebuild Yum repository metadata (repodata)<br>repository.yum.rebuild.metadata | Rebuilds the metadata for a Yum-hosted repository. This task runs automatically after an RPM is uploaded, deleted, or redeployed. The default wait time is 60 seconds. |
| ### Replicate content: target-repository-name<br>replication.pull | This task is automatically created to manage the schedule of content replication.<br>See [Content Replication Task](https://help.sonatype.com/en/content-replication.html#content-replication-task "Content Replication Task") |
| ### Replication - Backfill blob store attributes with component metadata<br>replication.blobattributesbackfill | Adds missing metadata to files in the blob store for replication. Wait until this task finishes before configuring a replication connection. |
| ### Repository - Delete unused components<br>repository.purge-unused | Use to soft-delete components not requested in the configured number of days from proxy repositories.<br>This task is replaced by the [Cleanup Policies](https://help.sonatype.com/en/cleanup-policies.html "Cleanup Policies"). |
| ### Repository - Import external files<br>repository.import | Use to import external content into a repository.<br>See [Repository Import](https://help.sonatype.com/en/repository-import.html "Repository Import") for details. |
| ### Repository - Export assets<br>repository.export | Use to export content from a repository.<br>See [Repository Export](https://help.sonatype.com/en/repository-export.html "Repository Export") for details. |
| ### Repository - Copy Blob Size to Asset Table<br>repository.metrics.blob.size.copy | Copies blob size information from the blob storage tables to the asset tables. This task repairs repository metrics when the “Size” column is missing or empty on the Repositories page.<br>Before running this task, the administrator must delete the existing completion records from the database:
```<br>DELETE FROM nexus_key_value WHERE key LIKE '%.blob.size.copy.completed';<br>```
|
| ### Rubygems - Generate SHA256 Checksums<br>repository.rubygems.generate-sha256-checksums | Generate sha256 checksums when missing from RubyGem metadata. |
| ### Repair - Rebuild Rubygems versions file<br>repository.ruby.rebuild.versions | Rebuild the `versions` file in hosted RubyGems repositories. Only run manually to repair a corrupted repository. |
| ### Statistics - Recalculate vulnerability statistics<br>repository.vulnerability.statistics | Provides the Log4j Visualizer with request log data. This task deletes the existing data that the visualizer is using and re-processes the logs.<br>See [Log4j Visualizer](https://help.sonatype.com/document/preview/116909#UUID-745f561b-5753-eec3-83a4-fcfaa090cc7b) for more details.Log4j Visualizer |
| ### Verify and Repair Data Consistency<br>blobstore.planReconciliation | **Do not use this task during normal operation of the server.**<br>See [Verify and Repair Data Consistency tasks](https://help.sonatype.com/en/verify-and-repair-data-consistency-tasks.html "Data Repair Tasks") |

### Reconcile Component Database From Blob Store Task

This task recovers lost component metadata from a blob store when restoring from backup, and the database and blob storage are out of sync. When executed, the task searches the selected blob store for blobs missing their associated metadata. The component metadata is restored based on the information contained in the blob store.

This task is replaced by the Verify and Repair Data Consistency tasks implemented in 3.83.0 release. This task should never be executed during normal operation of the server.

See [Verify and Repair Data Consistency tasks](https://help.sonatype.com/en/verify-and-repair-data-consistency-tasks.html "Data Repair Tasks")
