Skip to content

Commit 16c5690

Browse files
derrickstoleegitster
authored andcommitted
maintenance: include 'cron' details in docs
Advanced and expert users may want to know how 'git maintenance start' schedules background maintenance in order to customize their own schedules beyond what the maintenance.* config values allow. Start a new set of sections in git-maintenance.txt that describe how 'cron' is used to run these tasks. This is particularly valuable for users who want to inspect what Git is doing or for users who want to customize the schedule further. Having a baseline can provide a way forward for users who have never worked with cron schedules. Helped-by: Eric Sunshine <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 31345d5 commit 16c5690

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Documentation/git-maintenance.txt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,60 @@ Further, the `git gc` command should not be combined with
218218
but does not take the lock in the same way as `git maintenance run`. If
219219
possible, use `git maintenance run --task=gc` instead of `git gc`.
220220

221+
The following sections describe the mechanisms put in place to run
222+
background maintenance by `git maintenance start` and how to customize
223+
them.
224+
225+
BACKGROUND MAINTENANCE ON POSIX SYSTEMS
226+
---------------------------------------
227+
228+
The standard mechanism for scheduling background tasks on POSIX systems
229+
is cron(8). This tool executes commands based on a given schedule. The
230+
current list of user-scheduled tasks can be found by running `crontab -l`.
231+
The schedule written by `git maintenance start` is similar to this:
232+
233+
-----------------------------------------------------------------------
234+
# BEGIN GIT MAINTENANCE SCHEDULE
235+
# The following schedule was created by Git
236+
# Any edits made in this region might be
237+
# replaced in the future by a Git command.
238+
239+
0 1-23 * * * "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly
240+
0 0 * * 1-6 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=daily
241+
0 0 * * 0 "/<path>/git" --exec-path="/<path>" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly
242+
243+
# END GIT MAINTENANCE SCHEDULE
244+
-----------------------------------------------------------------------
245+
246+
The comments are used as a region to mark the schedule as written by Git.
247+
Any modifications within this region will be completely deleted by
248+
`git maintenance stop` or overwritten by `git maintenance start`.
249+
250+
The `crontab` entry specifies the full path of the `git` executable to
251+
ensure that the executed `git` command is the same one with which
252+
`git maintenance start` was issued independent of `PATH`. If the same user
253+
runs `git maintenance start` with multiple Git executables, then only the
254+
latest executable is used.
255+
256+
These commands use `git for-each-repo --config=maintenance.repo` to run
257+
`git maintenance run --schedule=<frequency>` on each repository listed in
258+
the multi-valued `maintenance.repo` config option. These are typically
259+
loaded from the user-specific global config. The `git maintenance` process
260+
then determines which maintenance tasks are configured to run on each
261+
repository with each `<frequency>` using the `maintenance.<task>.schedule`
262+
config options. These values are loaded from the global or repository
263+
config values.
264+
265+
If the config values are insufficient to achieve your desired background
266+
maintenance schedule, then you can create your own schedule. If you run
267+
`crontab -e`, then an editor will load with your user-specific `cron`
268+
schedule. In that editor, you can add your own schedule lines. You could
269+
start by adapting the default schedule listed earlier, or you could read
270+
the crontab(5) documentation for advanced scheduling techniques. Please
271+
do use the full path and `--exec-path` techniques from the default
272+
schedule to ensure you are executing the correct binaries in your
273+
schedule.
274+
221275

222276
GIT
223277
---

0 commit comments

Comments
 (0)