A command-line tool to manage systemd timers with YAML configuration files. This tool consolidates the .service and .timer file pair into a single YAML file and reduces multiple systemctl operations to a single command.
Managing systemd timers requires the following operations:
- Create a
.servicefile to define the task execution - Create a
.timerfile to define the schedule - Place both files in the appropriate directory
- Run
systemctl daemon-reload - Run
systemctl enable --now <timer-name>.timer
This tool reduces this workflow to a single YAML file and a single command, while leveraging native systemd capabilities.
- Single YAML file: Define both service and timer configuration in one place
- Direct systemd mapping: YAML structure mirrors native systemd unit file format
- Full systemd access: All systemd features available via official documentation
- Single command operation: One command to enable or disable timers
$ go install github.com/zinrai/systemd-timer-operator@latestEnable a timer:
$ sudo systemd-timer-operator enable examples/basic.ymlDisable a timer:
$ sudo systemd-timer-operator disable examples/basic.ymlGenerate unit files in the current directory:
$ systemd-timer-operator generate examples/basic.ymlFor YAML configuration examples, see the examples/ directory.
| Field | Description | Required |
|---|---|---|
Unit |
Common [Unit] section for both .service and .timer |
Optional |
Service |
[Service] section content |
Required |
Timer |
[Timer] section content |
Required |
TimerInstall |
[Install] section for .timer file |
Optional |
For use cases requiring different [Unit] sections for .service and .timer files:
| Field | Description |
|---|---|
ServiceUnit |
Dedicated [Unit] section for .service file (overrides Unit) |
TimerUnit |
Dedicated [Unit] section for .timer file (overrides Unit) |
ServiceInstall |
[Install] section for .service file |
- YAML to Unit File Mapping: The tool reads the YAML configuration and generates two systemd unit files (.service and .timer) by directly mapping YAML fields to INI-format sections
- Fallback Logic: If
ServiceUnitorTimerUnitfields are not specified, the commonUnitfield value is used for the respective[Unit]sections - File Placement: Generated unit files are placed in
/etc/systemd/system/with the prefixsystemd-timer-operator-to avoid naming conflicts - systemd Registration: The tool executes
systemctl daemon-reloadto register new units, thensystemctl enable --nowto activate the timer - Transparent Output: All systemctl command output is displayed as-is, without modification or filtering
- Validation Delegation: Configuration syntax and semantic validation are delegated to systemd. The tool only validates the presence of required YAML fields (
ServiceandTimer)
This project is licensed under the MIT License.