summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)