-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux systemd Timers Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to systemd timers on Linux, covering Arch Linux, CachyOS, and other distributions including creating timers, scheduling tasks, and replacing cron.
systemd timers are systemd's replacement for cron.
Advantages:
- Logging: Integrated with journald
- Dependencies: Can depend on other units
- Calendar: Flexible scheduling
- OnBoot/OnCalendar: Multiple trigger types
Components:
-
Timer unit:
.timerfile -
Service unit:
.servicefile (what to run)
Create service file:
# Create service
sudo vim /etc/systemd/system/my-task.serviceAdd:
[Unit]
Description=My Task
[Service]
Type=oneshot
ExecStart=/usr/bin/my-script.sh
Create timer file:
# Create timer
sudo vim /etc/systemd/system/my-task.timerAdd:
[Unit]
Description=Run My Task
[Timer]
OnCalendar=daily
OnBootSec=15min
[Install]
WantedBy=timers.target
OnCalendar syntax:
OnCalendar=Mon *-*-* 00:00:00 # Every Monday
OnCalendar=*-*-* 02:00:00 # Daily at 2 AM
OnCalendar=*-*-01 00:00:00 # Monthly on 1st
OnCalendar=hourly # Every hour
Relative timers:
OnBootSec=15min
OnUnitActiveSec=1h
OnStartupSec=10min
Enable and start:
# Enable timer
sudo systemctl enable my-task.timer
# Start timer
sudo systemctl start my-task.timer
# Check status
systemctl status my-task.timerView timers:
# List all timers
systemctl list-timers
# List active timers
systemctl list-timers --activeCheck status:
# Check timer
systemctl status my-task.timer
# Check service
systemctl status my-task.service
# Check logs
journalctl -u my-task.serviceCheck configuration:
# Test timer
systemctl list-timers my-task.timer
# Check service
systemctl cat my-task.serviceThis guide covered systemd timers, creating scheduled tasks, and timer management for Arch Linux, CachyOS, and other distributions.
- systemd Advanced - Advanced systemd
- System Configuration - System setup
- systemd Timers: https://wiki.archlinux.org/title/Systemd/Timers
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.