From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre Neidhardt Subject: Re: units_cur Date: Sun, 01 Apr 2018 18:36:05 +0530 Message-ID: <87in9bvzya.fsf@gmail.com> References: <87370l96az.fsf@gmail.com> <87a7ututad.fsf@gnu.org> <87tvsxizla.fsf@gmail.com> <87po3lldzs.fsf@gnu.org> <87efk0zwr7.fsf@gmail.com> <87lge8jk16.fsf@gnu.org> <87370ggpwc.fsf@gmail.com> <87bmf4jhm4.fsf@gnu.org> <87woxrbgel.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48659) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2cgZ-0002ot-FT for help-guix@gnu.org; Sun, 01 Apr 2018 09:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f2cgU-0000pv-Hs for help-guix@gnu.org; Sun, 01 Apr 2018 09:06:15 -0400 In-reply-to: <87woxrbgel.fsf@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: help-guix --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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.uni= ts")) (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 upstr= eam. ;; (next-hour-from (next-day) (list (tm:hour (localtime (current-ti= me))))) (+ (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? =2D- Pierre Neidhardt --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAlrA2T0ACgkQm9z0l6S7 zH9mkAf9FyRQS7BvIAVWL9kYzq/Nx3oxhNjoxuLO0uZzSTCI1NIxpnq6d0J9P55d RQvy+Hm5Qludc9YLoGaP9p3SOzfn96+xrSCVJCI1kd1ecOcexLPt7wE33o6ErIWX jXTzy8ogKFhFhmd5ovOpCBOs8lI3etcDnUFeMBPfBdY9JBpB+WBhjWn1/yI4vmnQ M6GnAyOcE07Wcc7TIceNF/lXb1s5Chw9fIYkcGBhNCdpgllpEbSAJGFK25e/jtHT Usb1x3zGXu/eRKuqp6Q7rXNP/a6/MCFiM9hmVn9oLXZzaidAaLAdg8qugGUSjK0m tZF/zOUaZiKKqdzpCTc+YEVN204Erw== =dI5K -----END PGP SIGNATURE----- --=-=-=--