Repository Management with Nexus
6.8. Managing Scheduled Tasks

6.8. Managing Scheduled Tasks

Nexus allows you to schedule tasks that will be applied to all repositories or to specific repositories on a configurable schedule. You can create the following kinds of scheduled tasks:

Download Indexes

This scheduled task will cause Nexus to download indexes from remote repositories.

Empty Trash

The Evict and Purge actions do not delete data from the Nexus working directory. They simply move data to be cleared or evicted to a trash directory under the Nexus work directory. This service deletes the data in this trash directory.

Evict Unused Proxied Items From Repository Caches

Use it or lose it. This scheduled task tells Nexus to get rid of all proxied items which haven't been "used" (referenced or retrieved by a client). This can be a good job to run if you are try to conserve storage space. In this service you can specify the number of days over which Nexus will look for activity before making the decision to evict an artifact. (See note about deletion.)

Optimize Repository Index

To speed up searches in Nexus, this task tells the internal search engine to optimize its index files. This has no affect on the indexes published by Nexus. Typically, this task does not have to run more than once a week.

Publish Indexes

Just as Maven downloads an index from a remote repository, Nexus can publish an index in the same format. This will make it easier for people using m2eclipse or Nexus to interact with your repositories.

Purge Nexus Timeline

Nexus maintains a lot of data that relates to the interaction between itself, proxied remote repositories, and clients on Nexus. While this information can be important for purposes of auditing, it can also take up storage space. Using this scheduled task you can tell Nexus to periodically purge this information. (See note about deletion.)

Rebuild Repository Attributes

This scheduled task tells Nexus to walk every file in a repository and gather information like checksums and file contents for every file.

Reindex Repositories

This service tells Nexus to reindex a repository.

Remove Snapshots from a Repository

Often, you will want to remove snapshots from a snapshot repository to preserve storage space. Note that configuring and running this job is not enough to reclaim disk space. You will also need to configure a scheduled job to empty the trash folder. Files are not deleted by the Remove Snapshots job, they are only moved into the Trash folder.

When you create a scheduled task to remove snapshots, you can specify:

  • Minimum Snapshots to preserve in a repository - This configuration option allows you to specify a minimum number of SNAPSHOTs to preserve per artifact. For example, if you configured this option with a value of 2, Nexus will always preserve at least two SNAPSHOT artifacts.

  • Snapshot Retention (in days) - This configuration option allows you to specify the number of days to retain SNAPSHOT artifacts. For example, if you want to make sure that you are always keeping the last three day's worth of SNAPSHOT artifacts, configure this option with a value of 3.

  • Whether snapshots should be removed if an artifact has been released - If your Nexus repository also contains a release repository, you can configure Nexus to remove all SNAPSHOT artifacts once an artifact has been released.

Synchronize Shadow Repository

This service synchronizes a shadow (or virtual) repository with its master repository.

Note

The Evict and Purge actions do not delete data from the Nexus working directory. They simply move data to be cleared or evicted to a trash directory under the Nexus work directory. If you want to reclaim disk space, you need to clear the Trash on the Browse Repositories screen. If something goes wrong with a evict of clear service, you can move the data back to the appropriate storage location from the trash. You can also schedule the Empty Trash service to clear this directory on a periodic basis.

When you create a new service you can configure it to apply to all repositories, the repositories in a Nexus Group, or a specific Nexus Repository. A service can be scheduled to run once at a specific date and time, or periodically once every Day, Week, or Month. If none of these options suit your specific needs, you can select a recurrence of "Advanced" which will allow you to supply your own cron expression to specify when the job should execute.

To create a new scheduled task, click on Scheduled Tasks under the Administration menu, and click on the Add button. This will bring up the screen shown in Figure 6.20, “Managing Nexus Scheduled Tasks”.

Managing Nexus Scheduled Tasks

Figure 6.20. Managing Nexus Scheduled Tasks


6.8.1. Managing Configuration Backups with a Scheduled Task

Nexus Professional includes a scheduled task which allows you to create automated, scheduled backups of your Nexus configuration. This scheduled job will archive the contents of the sonatype-work/nexus/conf directory. Figure 6.21, “Configuring a Scheduled Backup of Nexus Configuration” shows a scheduled configuration backup job configured to backup the contents of the Nexus configuration every day at 12:15 AM.

Configuring a Scheduled Backup of Nexus Configuration

Figure 6.21. Configuring a Scheduled Backup of Nexus Configuration


Once a backup has been run, the contents of the backup will be available in sonatype-work/nexus/backup in a series of ZIP archives which include the date and a timestamp.

Sonatype Promotion Subscribe via RSS