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.
The basic syntax for the garbage collection command is:
ssh -p <port> <user>@<host> gerrit gc [--all] [ <project> ... ]
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
Run garbage collection on all projects weekly at midnight Sunday.
0 0 * * sun -p 29418 admin@comet gerrit gc --all
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