GNU bug report logs - #38429
[PATCH] Add scron service.

Previous Next

Package: guix-patches;

Reported by: Robert Vollmert <rob <at> vllmrt.net>

Date: Fri, 29 Nov 2019 17:56:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Robert Vollmert <rob <at> vllmrt.net>
Subject: bug#38429: closed (Re: [bug#38429] [PATCH 1/5] document scron)
Date: Sun, 08 Dec 2019 02:47:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#38429: [PATCH] Add scron service.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 38429 <at> debbugs.gnu.org.

-- 
38429: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=38429
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: Robert Vollmert <rob <at> vllmrt.net>
Cc: 38429-done <at> debbugs.gnu.org
Subject: Re: [bug#38429] [PATCH 1/5] document scron
Date: Sun, 08 Dec 2019 00:46:40 +0100
Hi,

Robert Vollmert <rob <at> vllmrt.net> skribis:

> I’m sorry, for the moment this about as much effort as I’m willing
> to put into this. Feel free to close.

Done!

It’s a sad outcome though, given that the two of us had already spent
quite some time on it.  Oh well, maybe someone will pick it up later.

Ludo’.

[Message part 3 (message/rfc822, inline)]
From: Robert Vollmert <rob <at> vllmrt.net>
To: guix-patches <at> gnu.org
Cc: Robert Vollmert <rob <at> vllmrt.net>
Subject: [PATCH] Add scron service.
Date: Fri, 29 Nov 2019 18:53:56 +0100
It's a simple replacement for the mcron service.

If you have a mcron job definition like

(define cron-job
  #~(job "*/15 * * * *" #$(program-file ...)))

you can convert it into the valid scron job

(define cron-job
  (scron-job (schedule "/15 * * * *")
             (program-file ...)))

* gnu/services/scron.scm: New file.
* gnu/local.mk: Add it.
---
 gnu/local.mk           |  1 +
 gnu/services/scron.scm | 39 ++++++++++++++++++++++++---------------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 56ff1d0f7b..ca8b6ecc1b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -552,6 +552,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/services/nix.scm				\
   %D%/services/nfs.scm			\
   %D%/services/pam-mount.scm			\
+  %D%/services/scron.scm			\
   %D%/services/security-token.scm		\
   %D%/services/shepherd.scm			\
   %D%/services/sound.scm			\
diff --git a/gnu/services/scron.scm b/gnu/services/scron.scm
index dee0bad81e..0ea7cc9698 100644
--- a/gnu/services/scron.scm
+++ b/gnu/services/scron.scm
@@ -30,6 +30,11 @@
             scron-configuration-scron
             scron-configuration-jobs
 
+            scron-job
+            scron-job?
+            scron-job-schedule
+            scron-job-command
+
             scron-service-type
             scron-service))
 
@@ -40,7 +45,8 @@
 ;;
 ;;  (service scron-service-type
 ;;           (scron-configuration
-;;            (jobs (list (job "*/15 * * * *" "echo hello!")))))
+;;            (jobs (list (scron-job (schedule "*/15 * * * *")
+;;                                   (command  "echo hello!"))))))
 ;;;
 ;;; Code:
 
@@ -55,34 +61,37 @@
 (define-record-type* <scron-job> scron-job
   make-scron-job
   scron-job?
-  (schedule scron-job-schedule (default ""))
-  (command  scron-job-command  (default "")))
+  (schedule scron-job-schedule (default "* * * * *"))
+  (command  scron-job-command  (default '())))
 
 (define (crontab jobs)
-  (text-file "crontab"
-    (string-concatenate
+  (apply mixed-text-file "crontab"
+    (concatenate
       (map
         (match-lambda
           (($ <scron-job> schedule command)
-            (string-append schedule " " command "\n")))
+            (list schedule " " command "\n")))
         jobs))))
 
-(define scron-shepherd-service
+(define scron-shepherd-services
   (match-lambda
     (($ <scron-configuration> scron jobs)
-     (shepherd-service
-      (provision '(scron))
-      (requirement '(user-processes))
-      (start #~(make-forkexec-constructor
-                (list (string-append #$scron "/bin/crond") "-n" "-f" #$(crontab jobs))
-                #:log-file "/var/log/scron.log"))
-      (stop #~(make-kill-destructor))))))
+     (list
+       (shepherd-service
+        (provision '(scron))
+        (requirement '(user-processes))
+        (start #~(make-forkexec-constructor
+                  (list (string-append #$scron "/bin/crond")
+                        "-n" ; don't fork
+                        "-f" #$(crontab jobs))
+                  #:log-file "/var/log/scron.log"))
+        (stop #~(make-kill-destructor)))))))
 
 (define scron-service-type
   (service-type (name 'scron)
                 (extensions
                  (list (service-extension shepherd-root-service-type
-                                          (list scron-shepherd-service))))
+                                          scron-shepherd-services)))
                 (compose concatenate)
                 (extend (lambda (config jobs)
                           (scron-configuration
-- 
2.24.0




This bug report was last modified 5 years and 169 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.