Honk! My First Systemd Timer
Along with the update of Honk to version 1.2, I add a systemd timer to keep its database lean.
I add two files in /etc/systemd/system:
- honk-daily-cleanup.timer
- honk-daily-cleanup.service
honk-daily-cleanup.timer looks like this:
[Unit]
Description="Timer for the daily honk database cleanup"
[Timer]
Unit=honk-database-cleanup-timer.service
OnBootSec=30min
OnUnitActiveSec=1day
[Install]
WantedBy=timers.targetAnd honk-daily-cleanup.service is:
[Unit]
Description="Honk database cleanup" 
[Service]
Type=simple
WorkingDirectory=/usr/local/bin/honk
ExecStart=/usr/local/bin/honk/honk -datadir /var/lib/honk cleanup
User=honk
Group=honkI then add the timer like this:
enable honk-daily-cleanup.timerAnd this will run the service daily.
systemctl status honk-daily-cleanup.timerwill show something like:
● honk-daily-cleanup.timer - "Timer for the daily honk database cleanup"
     Loaded: loaded (/etc/systemd/system/honk-daily-cleanup.timer; enabled; preset: enabled)
     Active: active (waiting) since Wed 2023-12-27 11:12:08 CET; 1 day 22h ago
    Trigger: Fri 2023-12-29 11:12:11 CET; 1h 58min left
   Triggers: ● honk-daily-cleanup.service
systemd[1]: Started honk-daily-cleanup.timer - "Timer for the daily honk database cleanup".And
systemctl status honk-daily-cleanup.servicewill show something like:
○ honk-daily-cleanup.service - "Honk database cleanup"
     Loaded: loaded (/etc/systemd/system/honk-daily-cleanup.service; static)
     Active: inactive (dead) since Thu 2023-12-28 11:12:38 CET; 22h ago
   Duration: 27.498s
TriggeredBy: ● honk-daily-cleanup.timer
    Process: 2989903 ExecStart=/usr/local/bin/honk/honk -datadir /var/lib/honk cleanup (code=exited, status=0/SUCCESS)
   Main PID: 2989903 (code=exited, status=0/SUCCESS)
        CPU: 1.038s
Dec 28 11:12:11 systemd[1]: Started honk-daily-cleanup.service - "Honk database cleanup".
Dec 28 11:12:38 systemd[1]: honk-daily-cleanup.service: Deactivated successfully.
Dec 28 11:12:38 systemd[1]: honk-daily-cleanup.service: Consumed 1.038s CPU time.