Skip to content

Commit ed8794e

Browse files
committed
Merge branch 'lh/systemd-timers'
"git maintenance" scheduler learned to use systemd timers as a possible backend. * lh/systemd-timers: maintenance: add support for systemd timers on Linux maintenance: `git maintenance run` learned `--scheduler=<scheduler>` cache.h: Introduce a generic "xdg_config_home_for(…)" function
2 parents 76f5fdc + b681b19 commit ed8794e

File tree

5 files changed

+694
-80
lines changed

5 files changed

+694
-80
lines changed

Documentation/git-maintenance.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,17 @@ OPTIONS
179179
`maintenance.<task>.enabled` configured as `true` are considered.
180180
See the 'TASKS' section for the list of accepted `<task>` values.
181181

182+
--scheduler=auto|crontab|systemd-timer|launchctl|schtasks::
183+
When combined with the `start` subcommand, specify the scheduler
184+
for running the hourly, daily and weekly executions of
185+
`git maintenance run`.
186+
Possible values for `<scheduler>` are `auto`, `crontab`
187+
(POSIX), `systemd-timer` (Linux), `launchctl` (macOS), and
188+
`schtasks` (Windows). When `auto` is specified, the
189+
appropriate platform-specific scheduler is used; on Linux,
190+
`systemd-timer` is used if available, otherwise
191+
`crontab`. Default is `auto`.
192+
182193

183194
TROUBLESHOOTING
184195
---------------
@@ -277,6 +288,52 @@ schedule to ensure you are executing the correct binaries in your
277288
schedule.
278289

279290

291+
BACKGROUND MAINTENANCE ON LINUX SYSTEMD SYSTEMS
292+
-----------------------------------------------
293+
294+
While Linux supports `cron`, depending on the distribution, `cron` may
295+
be an optional package not necessarily installed. On modern Linux
296+
distributions, systemd timers are superseding it.
297+
298+
If user systemd timers are available, they will be used as a replacement
299+
of `cron`.
300+
301+
In this case, `git maintenance start` will create user systemd timer units
302+
and start the timers. The current list of user-scheduled tasks can be found
303+
by running `systemctl --user list-timers`. The timers written by `git
304+
maintenance start` are similar to this:
305+
306+
-----------------------------------------------------------------------
307+
$ systemctl --user list-timers
308+
NEXT LEFT LAST PASSED UNIT ACTIVATES
309+
Thu 2021-04-29 19:00:00 CEST 42min left Thu 2021-04-29 18:00:11 CEST 17min ago [email protected] [email protected]
310+
Fri 2021-04-30 00:00:00 CEST 5h 42min left Thu 2021-04-29 00:00:11 CEST 18h ago [email protected] [email protected]
311+
Mon 2021-05-03 00:00:00 CEST 3 days left Mon 2021-04-26 00:00:11 CEST 3 days ago [email protected] [email protected]
312+
-----------------------------------------------------------------------
313+
314+
One timer is registered for each `--schedule=<frequency>` option.
315+
316+
The definition of the systemd units can be inspected in the following files:
317+
318+
-----------------------------------------------------------------------
319+
~/.config/systemd/user/[email protected]
320+
~/.config/systemd/user/[email protected]
321+
~/.config/systemd/user/timers.target.wants/[email protected]
322+
~/.config/systemd/user/timers.target.wants/[email protected]
323+
~/.config/systemd/user/timers.target.wants/[email protected]
324+
-----------------------------------------------------------------------
325+
326+
`git maintenance start` will overwrite these files and start the timer
327+
again with `systemctl --user`, so any customization should be done by
328+
creating a drop-in file, i.e. a `.conf` suffixed file in the
329+
`~/.config/systemd/user/[email protected]` directory.
330+
331+
`git maintenance stop` will stop the user systemd timers and delete
332+
the above mentioned files.
333+
334+
For more details, see `systemd.timer(5)`.
335+
336+
280337
BACKGROUND MAINTENANCE ON MACOS SYSTEMS
281338
---------------------------------------
282339

0 commit comments

Comments
 (0)