summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2023-02-19 17:33:56 +0100
committerTimo Wilken2023-02-19 17:36:17 +0100
commit32152898cbaebbe7d7a5f6b41be0ec8d76a08fdc (patch)
tree8f316aac43b6ec2225db3dd1326f214f67a00e25
parent8e7b618a6177e423c1082ac7dc4f3d5047f45f58 (diff)
Simplify yt-dlp scheduling function further
This way of trying to schedule every second day doesn't actually work. Just run every night at the same hour and randomise the minutes.
-rw-r--r--tw/services/media.scm23
1 files changed, 7 insertions, 16 deletions
diff --git a/tw/services/media.scm b/tw/services/media.scm
index 34d25cf2..22a720fb 100644
--- a/tw/services/media.scm
+++ b/tw/services/media.scm
@@ -15,19 +15,10 @@
(define (string-or-gexp? value)
(or (string? value) (gexp? value)))
-(define (random-time-every-second-night day-predicate)
- #~(lambda (now)
- (next-minute-from
- (next-hour-from
- ;; If today's day number satisfies `day-predicate' (e.g. `even?'),
- ;; then run today, else tomorrow.
- (if (#$day-predicate (tm:yday (localtime now)))
- now
- (next-day-from now))
- ;; Between 1 and 6 a.m., randomly. The certbot service uses `random'
- ;; like this too, so it should be safe.
- (list (1+ (random 6))))
- (list (random 60)))))
+(define (random-minute hour)
+ ;; Choose a random minute of the hour. The certbot service uses
+ ;; `random' like this too, so it should be safe.
+ #~'(next-minute-from (next-hour '(#$hour)) (list (random 60))))
@@ -36,9 +27,9 @@
The service expects a @code{.yt-dlp} config directory inside this one.")
(yt-dlp (package-or-false yt-dlp) "The yt-dlp package to use; or
@code{#false} to use the yt-dlp script inside the config directory.")
- (schedule (string-or-gexp (random-time-every-second-night 'even?)) "The mcron
-schedule on which to run the download script. By default, picks a random time
-between 01:00 and 06:00 every second night.")
+ (schedule (string-or-gexp (random-minute 4)) "The mcron schedule on which to
+run the download script. By default, picks a random time between 04:00 and
+05:00 every night.")
(user (string "root") "The Unix user name to run the script as."))
(define (yt-dlp-cronjob config)