[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: units_cur
From: |
Pierre Neidhardt |
Subject: |
Re: units_cur |
Date: |
Sun, 01 Apr 2018 18:36:05 +0530 |
User-agent: |
mu4e 1.0; emacs 25.3.1 |
I want to update whenever the file is older than 1 day (so that it does
not do anything on reboot for instance) and every 1 day
from then on (so that it keeps updating even if I don't reboot).
For that I need mcron with some condition on the mtime of
currency.units.
Here is my implementation:
;; -*- mode: Lisp; -*-
;; This cannot be let-bound within `job'.
(define currency-file (string-append (getenv "HOME")
"/.cache/currency.units"))
(job
(lambda (current-time)
(let* ((seconds-in-a-day (* 60 60 24))
(currency-time (stat:mtime (stat currency-file))))
(if (< currency-time (- current-time seconds-in-a-day))
(next-second)
;; TODO: The following does not work while it should. Report
upstream.
;; (next-hour-from (next-day) (list (tm:hour (localtime
(current-time)))))
(+ (next-second) (- 86400 (- current-time currency-time))))))
;; A string is nicer than Scheme code for `mcron --schedule' output.
;; Other we could return '(system* "units_cur" currency-file)
(string-append "units_cur " currency-file))
I start ~mcron~ from my ~.profile~:
mcron &
Comments are welcome :)
Note: As mentioned in the "TODO:" above, I think there is a bug in
mcron. The following example taken from the Guix manual does not seem
to work:
(define idutils-job
;; Update the index database as user "charlie" at 12:15PM
;; and 19:15PM. This runs from the user's home directory.
#~(job '(next-minute-from (next-hour '(12 19)) '(15))
(string-append #$idutils "/bin/mkid src")
#:user "charlie"))
Or, at the user level:
(job '(next-minute-from (next-hour '(12 19)) '(15))
(string-append (getenv "HOME") "/.guix-profile/bin/mkid src"))
> mcron -s 1
mcron: Cannot read files in your ~/.config/cron (or ~/.cron) directory.
More specifically, it seems that mcron fails to take a list as second
argument to the ~next-*~ functions.
Can anyone confirm?
--
Pierre Neidhardt
signature.asc
Description: PGP signature
- Re: units_cur, Pierre Neidhardt, 2018/04/01
- Re: units_cur,
Pierre Neidhardt <=