Systemd Service / Timer

  1. Create Systemd Service File (e.g. wan-failover.service):

  • Purpose: Defines how the failover script is run and managed by systemd.

  • Key Sections:

    • [Unit]: Description, dependencies (e.g., network target)

    • [Service]: Specifies the script to execute (ExecStart), user/group, restart policy (e.g., always restart on failure)

    • [Install]: Defines when the service should be enabled (e.g., multi-user.target)

[Unit]
Description=WAN Failover Service
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/path/to/wan-failover.sh
Restart=on-failure
RestartSec=10
User=cardano

[Install]
WantedBy=multi-user.target
  • ExecStartPre=/bin/sleep 10: You might add a delay to allow network to initialize before running the script.

  1. Create Systemd Timer File (e.g. wan-failover.timer):

  • Purpose: Periodically triggers the failover script.

[Unit]
Description=Timer for WAN Failover Script
[Timer]
OnBootSec=1min
OnUnitActiveSec=30
AccuracySec=10

[Install]
WantedBy=timers.target
  • This example runs the timer 1 minute after boot and then every 30 seconds. You can adjust these settings

Last updated