From 1692a370b4f58fd3ad709605d0e502dcac2a5c07 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 23 Apr 2024 21:01:56 -0600 Subject: fuss with systemd timers --- aux/maintenance | 15 +++++++++++++++ aux/www-maintenance@.service | 8 ++++++++ aux/www-maintenance@daily.timer | 13 +++++++++++++ aux/www-maintenance@houry.timer | 12 ++++++++++++ aux/www-maintenance@weekly.timer | 11 +++++++++++ aux/www-refresh.service | 8 -------- aux/www-refresh.timer | 12 ------------ 7 files changed, 59 insertions(+), 20 deletions(-) create mode 100755 aux/maintenance create mode 100644 aux/www-maintenance@.service create mode 100644 aux/www-maintenance@daily.timer create mode 100644 aux/www-maintenance@houry.timer create mode 100644 aux/www-maintenance@weekly.timer delete mode 100644 aux/www-refresh.service delete mode 100644 aux/www-refresh.timer diff --git a/aux/maintenance b/aux/maintenance new file mode 100755 index 0000000..d529b49 --- /dev/null +++ b/aux/maintenance @@ -0,0 +1,15 @@ +#!/bin/sh +set -x + +case "$1" in + hourly) + rm -f -- .http-cache/'https%3A%2F%2F'*'%2Fapi%2Fv1%2Faccounts%2F'*'%2Fstatuses%3Fexclude_reblogs%3Dtrue%26tagged%3DDailyStandUp' + ;; + daily|weekly) + rm -rf -- .http-cache + ;; +esac + +make + +git -C .git-cache maintenance run --schedule="$1" diff --git a/aux/www-maintenance@.service b/aux/www-maintenance@.service new file mode 100644 index 0000000..b1b0c8b --- /dev/null +++ b/aux/www-maintenance@.service @@ -0,0 +1,8 @@ +[Unit] +Description=Website maintenance cron job + +[Service] +Type=oneshot +Environment=LANG=en_US.UTF-8 +WorkingDirectory=%h/www +ExecStart=%h/www/aux/maintenance %i diff --git a/aux/www-maintenance@daily.timer b/aux/www-maintenance@daily.timer new file mode 100644 index 0000000..ea2ee73 --- /dev/null +++ b/aux/www-maintenance@daily.timer @@ -0,0 +1,13 @@ +[Unit] +Description=Website maintenance daily cron job + +[Timer] +Persistent=true +# Run every day somewhere between 4am and 5am MDT (in the summer; +# between 3am and 4am MST in the winter), except for on Sunday, when +# the @weekly timer runs instead. +OnCalendar=Mon..Sat *-*-* 10:00:00 UTC +RandomizedDelaySec=1h + +[Install] +WantedBy=default.target diff --git a/aux/www-maintenance@houry.timer b/aux/www-maintenance@houry.timer new file mode 100644 index 0000000..dd29194 --- /dev/null +++ b/aux/www-maintenance@houry.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Website maintenance hourly cron job + +[Timer] +Persistent=true +# Run every hour, except for 10am UTC (see the @daily timer), when the +# @daily timer runs instead. +OnCalendar=*-*-* 0..9,11..23:00:00 UTC +RandomizedDelaySec=1h + +[Install] +WantedBy=default.target diff --git a/aux/www-maintenance@weekly.timer b/aux/www-maintenance@weekly.timer new file mode 100644 index 0000000..f5566e4 --- /dev/null +++ b/aux/www-maintenance@weekly.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Website maintenance weekly cron job + +[Timer] +Persistent=true +# Run every Sunday at 10am UTC (see the @daily timer). +OnCalendar=Sun 10:00:00 UTC +RandomizedDelaySec=1h + +[Install] +WantedBy=default.target diff --git a/aux/www-refresh.service b/aux/www-refresh.service deleted file mode 100644 index d6ecde1..0000000 --- a/aux/www-refresh.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Website update cron job - -[Service] -Type=oneshot -Environment=LANG=en_US.UTF-8 -WorkingDirectory=%h/www -ExecStart=sh -c 'rm -rf .http-cache && make && git -C .git-cache maintenance run' diff --git a/aux/www-refresh.timer b/aux/www-refresh.timer deleted file mode 100644 index d507e2f..0000000 --- a/aux/www-refresh.timer +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Website update cron job - -[Timer] -Persistent=true -# somewhere between 4am and 5am MDT (in the summer; -# between 3am and 4am MST in the winter) -OnCalendar=*-*-* 10:00:00 UTC -RandomizedDelaySec=1h - -[Install] -WantedBy=default.target -- cgit v1.2.3