Systemd timers are a powerful alternative to cron for scheduling tasks, especially when you want better integration with system events like startup or specific conditions. Example of creating a simple systemd timer is given below -
[Unit]
Description=Example Systemd Service File.
[Service]
Type=oneshot
User=<username>
ExecStart=/usr/bin/ping -c 10 google.com
[Install]
WantedBy=multi-user.target
[Unit]
Description=Example Systemd Timer.
[Timer]
OnBootSec=5m
[Install]
WantedBy=timers.target
Note: OnBootSec=5m ensures the service starts 5 minutes after the system boots up. Adjust the value based on your needs (e.g., 10s for 10 seconds)
sudo systemctl enable test_timer.timer
sudo systemctl start test_timer.timer
To check if the Systemd timer is enabled, we can use systemctl list-timers command to list out the various Systemd timer enabled on the system.
Source(s):