mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 10:58:28 +00:00
28 lines
1.2 KiB
Org Mode
28 lines
1.2 KiB
Org Mode
|
:PROPERTIES:
|
||
|
:ID: a602f900-cdcf-4090-9278-d5926d80eedc
|
||
|
:END:
|
||
|
#+title: systemd transient units
|
||
|
#+date: 2021-08-02 12:01:49 +08:00
|
||
|
#+date_modified: 2022-04-16 20:01:51 +08:00
|
||
|
#+language: en
|
||
|
|
||
|
|
||
|
You can create units on-the-go with =systemd-run=.
|
||
|
Very useful for quickly creating and scheduling one-off services.
|
||
|
This tool mainly involves [[id:cd5f0d04-d9bb-44e8-a0f2-630ea58c1e94][systemd services]] and [[id:f1b21fc8-86a5-47cd-b3d8-da6ac7a34427][systemd timers]].
|
||
|
|
||
|
Like most systemd-related binaries, this can be run at system- and user-level (see [[id:c7edff80-6dea-47fc-8ecd-e43b5ab8fb1e][systemd at user-level]]).
|
||
|
|
||
|
#+begin_src shell
|
||
|
# This will create a user-level service file with the given command as the task.
|
||
|
systemd-run --user borgmatic --config emergency-config.yaml --verbose
|
||
|
|
||
|
# Create a transient timer for the service.
|
||
|
systemd-run --user borg-backup@external-drive.service --on-calendar=12:00
|
||
|
#+end_src
|
||
|
|
||
|
The result should give you the generated name of the unit.
|
||
|
Then, they can be managed like an ordinary unit.
|
||
|
Unit generated this way will persist until the next boot.
|
||
|
If you want to manage them on a permanent basis, create the appropriate unit files for them.
|