Set Up Gerrit Code Review Garbage Collection

Note: This section is for system administrators only.

Gerrit Code Review garbage collection (gerrit gc) is a command that converts loose objects to packed, and that also removes unused objects. We recommend that you run garbage collection on a regular basis to avoid performance problems associated with loose objects that occur over time.

This topic provides general examples of cron jobs you can use to set up garbage collection for your site. Syntax and supported features for cron jobs can vary across platforms. For more information, refer to cron and crontab documentation for your platform.

Note: Consider running garbage collection on all of your projects on a regular basis. Choose a "quiet" time that will be unlikely to interfere with repository users.

Gerrit gc Syntax

The basic syntax for the garbage collection command is:

ssh -p <port> <user>@<host> gerrit gc [--all] [ <project> ... ]
GitCentric port number, typically 29418.
User with Gerrit Code Review Administrate Server privileges.
Name of the GitCentric host machine.
runs garbage collection on all projects in the repository.
Name of one or more individual projects in which you want to run garbage collection.

cron job Examples

You use cron jobs to execute commands, like gerrit gc, on a scheduled basis. The cron job format is a sequence of five fields used to specify day, time, and frequency. The sixth is used to specify the command:

Field Description Allowed Values
MIN Minute of the hour 0 to 59, *
HOUR Hour of the day 0 to 23, *
DOM Day of the month 1 to 31, *
MON Month 1 to 12, *
DOW Day of the week 0 to 6; *; sun, mon, tue, wed, thu, fri, sat
CMD Command The command to be executed

The following examples show how you can use cron jobs to run garbage collection on your Gerrit projects. In these examples, comet is the name of the GitCentric GUI host machine.

Run garbage collection on all projects at midnight every day of the week.

0 0 * * * ssh -p 29418 admin@comet gerrit gc --all
Tip: You can use the keyword @daily to express 0 0 * * *.

Run garbage collection on all projects weekly at midnight Sunday.

0 0 * * sun -p 29418 admin@comet gerrit gc --all
Tip: You can use the keyword @weekly to express 0 0 * * 0 (which is the equivalent of 0 0 * * sun).

Run garbage collection on acme and phoenix projects Monday through Friday at 1:30 a.m.

0 0 * * 1-5 ssh -p 29418 admin@comet gerrit gc acme phoenix