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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Robert Vollmert <rob@HIDDEN>; Keywords: patch; Done: Ludovic Courtès <ludo@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 38429-done <at> debbugs.gnu.org:


Received: (at 38429-done) by debbugs.gnu.org; 8 Dec 2019 02:46:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 07 21:46:26 2019
Received: from localhost ([127.0.0.1]:50024 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1idmaY-0007Ls-MB
	for submit <at> debbugs.gnu.org; Sat, 07 Dec 2019 21:46:26 -0500
Received: from eggs.gnu.org ([209.51.188.92]:49552)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1idmaX-0007Gv-Mj
 for 38429-done <at> debbugs.gnu.org; Sat, 07 Dec 2019 21:46:25 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:39052)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1idjme-0006Jj-Hw; Sat, 07 Dec 2019 18:46:47 -0500
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=54608 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1idjme-0004jF-25; Sat, 07 Dec 2019 18:46:44 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Robert Vollmert <rob@HIDDEN>
Subject: Re: [bug#38429] [PATCH 1/5] document scron
References: <20191129175356.12403-1-rob@HIDDEN>
 <20191203124632.1987-1-rob@HIDDEN> <87fthvsodt.fsf@HIDDEN>
 <996CDF7A-67DD-4807-B925-A686B49B8EA2@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 18 Frimaire an 228 de la =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Sun, 08 Dec 2019 00:46:40 +0100
In-Reply-To: <996CDF7A-67DD-4807-B925-A686B49B8EA2@HIDDEN> (Robert
 Vollmert's message of "Sun, 8 Dec 2019 00:43:40 +0100")
Message-ID: <87blsjsnq7.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38429-done
Cc: 38429-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

Robert Vollmert <rob@HIDDEN> skribis:

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

Done!

It=E2=80=99s a sad outcome though, given that the two of us had already spe=
nt
quite some time on it.  Oh well, maybe someone will pick it up later.

Ludo=E2=80=99.




Notification sent to Robert Vollmert <rob@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Ludovic Courtès <ludo@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 3 Dec 2019 12:50:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 03 07:50:34 2019
Received: from localhost ([127.0.0.1]:39397 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ic7dS-0002fW-7N
	for submit <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:50:34 -0500
Received: from mout-p-201.mailbox.org ([80.241.56.171]:50910)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1ic7dQ-0002fJ-Km
 for 38429 <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:50:33 -0500
Received: from smtp2.mailbox.org (smtp2.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:2:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-201.mailbox.org (Postfix) with ESMTPS id 47S1zk0qk3zQlB0
 for <38429 <at> debbugs.gnu.org>; Tue,  3 Dec 2019 13:50:26 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp2.mailbox.org ([80.241.60.241])
 by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de
 [80.241.56.123]) (amavisd-new, port 10030)
 with ESMTP id 270GPLV2imJv for <38429 <at> debbugs.gnu.org>;
 Tue,  3 Dec 2019 13:50:23 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
Subject: Re: [PATCH 4/5] scron: add system test
Date: Tue, 3 Dec 2019 13:50:22 +0100
References: <20191203124632.1987-1-rob@HIDDEN>
 <20191203124632.1987-4-rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
In-Reply-To: <20191203124632.1987-4-rob@HIDDEN>
Message-Id: <1207941E-B025-4E37-88EE-E8AABD91C1CB@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

I=E2=80=99ve checked that the tests compile, and run the test cron jobs
by hand to ensure they behave as tested, but I wasn=E2=80=99t able to =
run
the system tests themselves.

> On 3. Dec 2019, at 13:46, Robert Vollmert <rob@HIDDEN> wrote:
>=20
> ---
> gnu/tests/base.scm | 86 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 86 insertions(+)
>=20
> diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
> index a891711844..b80e77be66 100644
> --- a/gnu/tests/base.scm
> +++ b/gnu/tests/base.scm
> @@ -28,6 +28,7 @@
>   #:use-module (gnu services dbus)
>   #:use-module (gnu services avahi)
>   #:use-module (gnu services mcron)
> +  #:use-module (gnu services scron)
>   #:use-module (gnu services shepherd)
>   #:use-module (gnu services networking)
>   #:use-module (gnu packages base)
> @@ -48,6 +49,7 @@
>             %test-halt
>             %test-cleanup
>             %test-mcron
> +            %test-scron
>             %test-nss-mdns))
>=20
> (define %simple-os
> @@ -720,6 +722,90 @@ non-ASCII names from /tmp.")
>    (description "Make sure the mcron service works as advertised.")
>    (value (run-mcron-test name))))
>=20
> +=0C
> +;;;
> +;;; Scron.
> +;;;
> +
> +(define %scron-os
> +  ;; System with an scron service, with one scron job for "root" and =
one scron
> +  ;; job for an unprivileged user.
> +  (let ((job1
> +         (scron-job
> +          (schedule "* * * * *")
> +          (command  "(id -u; id -g) > witness")))
> +        (job2
> +         (scron-job
> +          (schedule "* * * * *")
> +          (command  "su -c '(id -u; id -g) > ~/witness' alice")))
> +        (job3
> +         (scron-job
> +          (schedule "* * * * *")
> +          (command  "touch witness-touch"))))
> +    (simple-operating-system
> +     (service scron-service-type
> +              (scron-configuration (jobs (list job1 job2 job3)))))))
> +
> +(define (run-scron-test name)
> +  (define os
> +    (marionette-operating-system
> +     %scron-os
> +     #:imported-modules '((gnu services herd)
> +                          (guix combinators))))
> +
> +  (define test
> +    (with-imported-modules '((gnu build marionette))
> +      #~(begin
> +          (use-modules (gnu build marionette)
> +                       (srfi srfi-64)
> +                       (ice-9 match))
> +
> +          (define marionette
> +            (make-marionette (list #$(virtual-machine os))))
> +
> +          (mkdir #$output)
> +          (chdir #$output)
> +
> +          (test-begin "scron")
> +
> +          (test-assert "service running"
> +            (marionette-eval
> +             '(begin
> +                (use-modules (gnu services herd))
> +                (start-service 'scron))
> +             marionette))
> +
> +          ;; Make sure root's scron job runs, has its cwd set to "/", =
and
> +          ;; runs with the right UID/GID.
> +          (test-equal "root's job"
> +            '(0 0)
> +            (wait-for-file "/witness" marionette))
> +
> +          ;; Likewise for Alice's job.  We cannot know what its GID =
is since
> +          ;; it's chosen by 'groupadd', but it's strictly positive.
> +          (test-assert "alice's job"
> +            (match (wait-for-file "/home/alice/witness" marionette)
> +              ((1000 gid)
> +               (>=3D gid 100))))
> +
> +          ;; Last, the job that uses a command; allows us to test =
whether
> +          ;; $PATH is sane.
> +          (test-equal "root's job with command"
> +            ""
> +            (wait-for-file "/witness-touch" marionette
> +                           #:read '(@ (ice-9 rdelim) read-string)))
> +
> +          (test-end)
> +          (exit (=3D (test-runner-fail-count (test-runner-current)) =
0)))))
> +
> +  (gexp->derivation name test))
> +
> +(define %test-scron
> +  (system-test
> +   (name "scron")
> +   (description "Make sure the scron service works as advertised.")
> +   (value (run-scron-test name))))
> +
>=20
> ;;;
> ;;; Avahi and NSS-mDNS.
> --=20
> 2.24.0
>=20





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 3 Dec 2019 12:49:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 03 07:49:18 2019
Received: from localhost ([127.0.0.1]:39392 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ic7cD-0002dM-Q8
	for submit <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:49:18 -0500
Received: from mout-p-101.mailbox.org ([80.241.56.151]:37292)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1ic7cC-0002d8-1B
 for 38429 <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:49:16 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-101.mailbox.org (Postfix) with ESMTPS id 47S1yF2W4yzKmdL;
 Tue,  3 Dec 2019 13:49:09 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de
 [80.241.56.115]) (amavisd-new, port 10030)
 with ESMTP id kE_CjPF4Od5C; Tue,  3 Dec 2019 13:49:06 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
Subject: [PATCH 5/5] gnu/services: Add description to mcron-service-type.
Date: Tue,  3 Dec 2019 13:46:34 +0100
Message-Id: <20191203124632.1987-5-rob@HIDDEN>
In-Reply-To: <20191203124632.1987-1-rob@HIDDEN>
References: <20191203124632.1987-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* gnu/services/mcron.go (mcron-service-type): Add description.
---

This one is independent from the scron patches.

 gnu/services/mcron.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm
index 7238665404..1327516b49 100644
--- a/gnu/services/mcron.scm
+++ b/gnu/services/mcron.scm
@@ -130,6 +130,8 @@ files."
 
 (define mcron-service-type
   (service-type (name 'mcron)
+                (description
+                 "Run the mcron job scheduling daemon.")
                 (extensions
                  (list (service-extension shepherd-root-service-type
                                           mcron-shepherd-services)
-- 
2.24.0





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 3 Dec 2019 12:48:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 03 07:48:37 2019
Received: from localhost ([127.0.0.1]:39382 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ic7bZ-0002bT-4V
	for submit <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:37 -0500
Received: from mout-p-202.mailbox.org ([80.241.56.172]:21246)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1ic7bX-0002as-Bo
 for 38429 <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:35 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:1:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 47S1xT544PzQlD6;
 Tue,  3 Dec 2019 13:48:29 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de
 [80.241.56.115]) (amavisd-new, port 10030)
 with ESMTP id CHzHop4GUSL8; Tue,  3 Dec 2019 13:48:21 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
Subject: [PATCH 3/5] scron: Add description
Date: Tue,  3 Dec 2019 13:46:31 +0100
Message-Id: <20191203124632.1987-3-rob@HIDDEN>
In-Reply-To: <20191203124632.1987-1-rob@HIDDEN>
References: <20191203124632.1987-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

---
 gnu/services/scron.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gnu/services/scron.scm b/gnu/services/scron.scm
index 990ae8f0e2..b9b2983e96 100644
--- a/gnu/services/scron.scm
+++ b/gnu/services/scron.scm
@@ -89,6 +89,8 @@
 
 (define scron-service-type
   (service-type (name 'scron)
+                (description
+                 "Run the scron job scheduling daemon.")
                 (extensions
                  (list (service-extension shepherd-root-service-type
                                           scron-shepherd-services)))
-- 
2.24.0





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 3 Dec 2019 12:48:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 03 07:48:36 2019
Received: from localhost ([127.0.0.1]:39380 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ic7bX-0002bQ-Ps
	for submit <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:36 -0500
Received: from mout-p-202.mailbox.org ([80.241.56.172]:21244)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1ic7bV-0002ai-RE
 for 38429 <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:34 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:1:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 47S1xQ4QNgzQlD5;
 Tue,  3 Dec 2019 13:48:26 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de
 [80.241.56.117]) (amavisd-new, port 10030)
 with ESMTP id YkE2kizTB8k9; Tue,  3 Dec 2019 13:48:23 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
Subject: [PATCH 4/5] scron: add system test
Date: Tue,  3 Dec 2019 13:46:32 +0100
Message-Id: <20191203124632.1987-4-rob@HIDDEN>
In-Reply-To: <20191203124632.1987-1-rob@HIDDEN>
References: <20191203124632.1987-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

---
 gnu/tests/base.scm | 86 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index a891711844..b80e77be66 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -28,6 +28,7 @@
   #:use-module (gnu services dbus)
   #:use-module (gnu services avahi)
   #:use-module (gnu services mcron)
+  #:use-module (gnu services scron)
   #:use-module (gnu services shepherd)
   #:use-module (gnu services networking)
   #:use-module (gnu packages base)
@@ -48,6 +49,7 @@
             %test-halt
             %test-cleanup
             %test-mcron
+            %test-scron
             %test-nss-mdns))
 
 (define %simple-os
@@ -720,6 +722,90 @@ non-ASCII names from /tmp.")
    (description "Make sure the mcron service works as advertised.")
    (value (run-mcron-test name))))
 
+
+;;;
+;;; Scron.
+;;;
+
+(define %scron-os
+  ;; System with an scron service, with one scron job for "root" and one scron
+  ;; job for an unprivileged user.
+  (let ((job1
+         (scron-job
+          (schedule "* * * * *")
+          (command  "(id -u; id -g) > witness")))
+        (job2
+         (scron-job
+          (schedule "* * * * *")
+          (command  "su -c '(id -u; id -g) > ~/witness' alice")))
+        (job3
+         (scron-job
+          (schedule "* * * * *")
+          (command  "touch witness-touch"))))
+    (simple-operating-system
+     (service scron-service-type
+              (scron-configuration (jobs (list job1 job2 job3)))))))
+
+(define (run-scron-test name)
+  (define os
+    (marionette-operating-system
+     %scron-os
+     #:imported-modules '((gnu services herd)
+                          (guix combinators))))
+
+  (define test
+    (with-imported-modules '((gnu build marionette))
+      #~(begin
+          (use-modules (gnu build marionette)
+                       (srfi srfi-64)
+                       (ice-9 match))
+
+          (define marionette
+            (make-marionette (list #$(virtual-machine os))))
+
+          (mkdir #$output)
+          (chdir #$output)
+
+          (test-begin "scron")
+
+          (test-assert "service running"
+            (marionette-eval
+             '(begin
+                (use-modules (gnu services herd))
+                (start-service 'scron))
+             marionette))
+
+          ;; Make sure root's scron job runs, has its cwd set to "/", and
+          ;; runs with the right UID/GID.
+          (test-equal "root's job"
+            '(0 0)
+            (wait-for-file "/witness" marionette))
+
+          ;; Likewise for Alice's job.  We cannot know what its GID is since
+          ;; it's chosen by 'groupadd', but it's strictly positive.
+          (test-assert "alice's job"
+            (match (wait-for-file "/home/alice/witness" marionette)
+              ((1000 gid)
+               (>= gid 100))))
+
+          ;; Last, the job that uses a command; allows us to test whether
+          ;; $PATH is sane.
+          (test-equal "root's job with command"
+            ""
+            (wait-for-file "/witness-touch" marionette
+                           #:read '(@ (ice-9 rdelim) read-string)))
+
+          (test-end)
+          (exit (= (test-runner-fail-count (test-runner-current)) 0)))))
+
+  (gexp->derivation name test))
+
+(define %test-scron
+  (system-test
+   (name "scron")
+   (description "Make sure the scron service works as advertised.")
+   (value (run-scron-test name))))
+
 
 ;;;
 ;;; Avahi and NSS-mDNS.
-- 
2.24.0





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 3 Dec 2019 12:48:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 03 07:48:31 2019
Received: from localhost ([127.0.0.1]:39376 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ic7bT-0002b5-FM
	for submit <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:31 -0500
Received: from mout-p-201.mailbox.org ([80.241.56.171]:50818)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1ic7bR-0002ab-Rp
 for 38429 <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:30 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-201.mailbox.org (Postfix) with ESMTPS id 47S1xM03xfzQlCC;
 Tue,  3 Dec 2019 13:48:23 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172])
 (amavisd-new, port 10030)
 with ESMTP id Twmtn6ssUs8F; Tue,  3 Dec 2019 13:48:20 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
Subject: [PATCH 2/5] scron-service: remove job defaults
Date: Tue,  3 Dec 2019 13:46:30 +0100
Message-Id: <20191203124632.1987-2-rob@HIDDEN>
In-Reply-To: <20191203124632.1987-1-rob@HIDDEN>
References: <20191203124632.1987-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

---
 gnu/services/scron.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/services/scron.scm b/gnu/services/scron.scm
index 0ea7cc9698..990ae8f0e2 100644
--- a/gnu/services/scron.scm
+++ b/gnu/services/scron.scm
@@ -61,8 +61,8 @@
 (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)
+  (command  scron-job-command))
 
 (define (crontab jobs)
   (apply mixed-text-file "crontab"
-- 
2.24.0





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 3 Dec 2019 12:48:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Dec 03 07:48:30 2019
Received: from localhost ([127.0.0.1]:39373 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ic7bS-0002aq-0I
	for submit <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:30 -0500
Received: from mout-p-101.mailbox.org ([80.241.56.151]:37264)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1ic7bP-0002aX-Bw
 for 38429 <at> debbugs.gnu.org; Tue, 03 Dec 2019 07:48:28 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:1:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-101.mailbox.org (Postfix) with ESMTPS id 47S1xH00qwzKmhD;
 Tue,  3 Dec 2019 13:48:19 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de
 [80.241.56.115]) (amavisd-new, port 10030)
 with ESMTP id sRLwjYcAnGsl; Tue,  3 Dec 2019 13:48:15 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
Subject: [PATCH 1/5] document scron
Date: Tue,  3 Dec 2019 13:46:29 +0100
Message-Id: <20191203124632.1987-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* doc/guix.texi: Add documentation for scron-service.
---

The first in a series of supplementary patches on top of the base scron
service patch, to be squashed into that commit.

 doc/guix.texi | 100 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 99 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index e0b831c7e8..1aafa01166 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -283,7 +283,7 @@ System Configuration
 Services
 
 * Base Services::               Essential system services.
-* Scheduled Job Execution::     The mcron service.
+* Scheduled Job Execution::     Cron services.
 * Log Rotation::                The rottlog service.
 * Networking Services::         Network setup, SSH daemon, etc.
 * X Window::                    Graphical display.
@@ -12890,6 +12890,104 @@ specifications,, mcron, GNU@tie{}mcron}).
 @end deftp
 
 
+@cindex scron
+@cindex scheduling jobs
+The @code{(gnu services scron)} module provides an interface to
+scron, a simple daemon to run jobs at scheduled times. scron is
+similar to the traditional Unix @command{cron} daemon;
+the main difference is that it is much simpler.
+
+Jobs are executed as root via the shell with working direction @code{/}.
+Use @code{su(1)} or corresponding Guile functions
+(@pxref{Processes,,, guile, GNU Guile Reference Manual}).
+
+The example below defines an operating system that runs the
+@command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
+and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
+well as the @command{mkid} command on behalf of an unprivileged user
+(@pxref{mkid invocation,,, idutils, ID Database Utilities}).
+
+@lisp
+(use-modules (guix) (gnu) (gnu services scron))
+(use-package-modules base idutils)
+
+(define updatedb-job
+  ;; Run 'updatedb' at 3AM every day.  Here we write the
+  ;; job's action as a Scheme procedure.
+  (let*
+    ((exp #~(begin
+              (execl (string-append #$findutils "/bin/updatedb")
+                     "updatedb"
+                     "--prunepaths=/tmp /var/tmp /gnu/store")))
+     (script (program-file "updatedb-job" exp))
+    (scron-job
+      (schedule "0 3 * * *")
+      (command  script))))
+
+(define garbage-collector-job
+  ;; Collect garbage 5 minutes after midnight every day.
+  ;; The job's action is a shell command.
+  (scron-job
+    (schedule "5 0 * * *")
+    (command  "guix gc -F 1G")))
+
+(define idutils-job
+  ;; Update the index database as user "charlie" at 12:15PM
+  ;; and 19:15PM.  This runs from the user's home directory.
+  (let*
+    ((cmd      #~(string-append #$idutils "/bin/mkid src"))
+     (cmd-su   #~(string-append "su -c '" #$cmd "' charlie")))
+    (scron-job
+      (schedule "15 12,19 * * *")
+      (command  cmd-su))))
+
+(operating-system
+  ;; @dots{}
+  (services (cons (service scron-service-type
+                           (scron-configuration
+                            (jobs (list garbage-collector-job
+                                        updatedb-job
+                                        idutils-job))))
+                  %base-services)))
+@end lisp
+
+@defvr {Scheme Variable} scron-service-type
+
+This is the type of the @code{scron} service, whose value is an
+@code{scron-configuration} object.
+
+This service type can be the target of a service extension that provides
+it additional job specifications (@pxref{Service Composition}).  In
+other words, it is possible to define services that provide additional
+mcron jobs to run.
+@end defvr
+
+@deftp {Data Type} scron-configuration
+Data type representing the configuration of scron.
+
+@table @asis
+@item @code{scron} (default: @var{scron})
+The scron package to use.
+
+@item @code{jobs}
+This is a list of scron jobs.
+@end table
+@end deftp
+
+@deftp {Data Type} scron-job
+Data type representing an scron job.
+
+@table @asis
+@item @code{schedule}
+The job schedule, in Vixie cron syntax. See the @code{scron(1)}
+man page for more information.
+
+@item @code{command}
+The shell command to run, as a value that lowers to a string.
+@end table
+@end deftp
+
+
 @node Log Rotation
 @subsection Log Rotation
 
-- 
2.24.0





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 2 Dec 2019 08:45:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 02 03:45:28 2019
Received: from localhost ([127.0.0.1]:37034 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ibhKi-0001Zo-DL
	for submit <at> debbugs.gnu.org; Mon, 02 Dec 2019 03:45:28 -0500
Received: from eggs.gnu.org ([209.51.188.92]:39260)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1ibhKh-0001Zc-09
 for 38429 <at> debbugs.gnu.org; Mon, 02 Dec 2019 03:45:27 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e]:60759)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1ibhKZ-0006sc-KQ; Mon, 02 Dec 2019 03:45:19 -0500
Received: from [62.102.229.57] (port=18827 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1ibhKP-00009F-Ol; Mon, 02 Dec 2019 03:45:19 -0500
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Robert Vollmert <rob@HIDDEN>
Subject: Re: [bug#38429] [PATCH] Add scron service.
References: <20191129175356.12403-1-rob@HIDDEN>
 <20191129180721.13923-1-rob@HIDDEN>
Date: Mon, 02 Dec 2019 10:01:56 +0100
In-Reply-To: <20191129180721.13923-1-rob@HIDDEN> (Robert Vollmert's
 message of "Fri, 29 Nov 2019 19:07:22 +0100")
Message-ID: <87r21nksmz.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 38429
Cc: 38429 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hello!

Robert Vollmert <rob@HIDDEN> skribis:

> 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 ...)))

Nice.

> +(define scron-service-type
> +  (service-type (name 'scron)
> +                (extensions
> +                 (list (service-extension shepherd-root-service-type
> +                                          scron-shepherd-services)))
> +                (compose concatenate)
> +                (extend (lambda (config jobs)
> +                          (scron-configuration
> +                           (inherit config)
> +                           (jobs (append (scron-configuration-jobs confi=
g)
> +                                         jobs)))))
> +                (default-value (scron-configuration))))

Could you add a =E2=80=98description=E2=80=99 field with a short blurb (you=
 can use
Texinfo markup)?

Also, could you add it to guix.texi, presumably under =E2=80=9CScheduled Job
Execution=E2=80=9D?

Last, it would be great if you could add a test, similar to the mcron
test that=E2=80=99s in (gnu tests base).

Thanks in advance!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at 38429 <at> debbugs.gnu.org:


Received: (at 38429) by debbugs.gnu.org; 29 Nov 2019 18:08:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 29 13:08:45 2019
Received: from localhost ([127.0.0.1]:33549 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iakhB-0007Sa-Cx
	for submit <at> debbugs.gnu.org; Fri, 29 Nov 2019 13:08:45 -0500
Received: from mout-p-101.mailbox.org ([80.241.56.151]:42810)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1iakh6-0007SK-Td
 for 38429 <at> debbugs.gnu.org; Fri, 29 Nov 2019 13:08:44 -0500
Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-101.mailbox.org (Postfix) with ESMTPS id 47PjDf43LqzKm5X;
 Fri, 29 Nov 2019 19:08:34 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp2.mailbox.org ([80.241.60.241])
 by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de
 [80.241.56.116]) (amavisd-new, port 10030)
 with ESMTP id 9Ozc9nEr-dns; Fri, 29 Nov 2019 19:08:30 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: 38429 <at> debbugs.gnu.org
Subject: [PATCH] Add scron service.
Date: Fri, 29 Nov 2019 19:07:22 +0100
Message-Id: <20191129180721.13923-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 38429
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

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.
---

Sent an incomplete patch before, this is the full version.

 gnu/local.mk           |   1 +
 gnu/services/scron.scm | 101 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+)
 create mode 100644 gnu/services/scron.scm

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
new file mode 100644
index 0000000000..0ea7cc9698
--- /dev/null
+++ b/gnu/services/scron.scm
@@ -0,0 +1,101 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Robert Vollmert <rob@HIDDEN>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services scron)
+  #:use-module (gnu services)
+  #:use-module (gnu services shepherd)
+  #:autoload   (gnu packages suckless) (scron)
+  #:use-module (guix gexp)
+  #:use-module (guix records)
+  #:use-module (guix store)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
+  #:export (scron-configuration
+            scron-configuration?
+            scron-configuration-scron
+            scron-configuration-jobs
+
+            scron-job
+            scron-job?
+            scron-job-schedule
+            scron-job-command
+
+            scron-service-type
+            scron-service))
+
+;;; Commentary:
+;;;
+;;; This module implements a service to run instances of scron, a
+;;; periodic job execution daemon.  Example of a service:
+;;
+;;  (service scron-service-type
+;;           (scron-configuration
+;;            (jobs (list (scron-job (schedule "*/15 * * * *")
+;;                                   (command  "echo hello!"))))))
+;;;
+;;; Code:
+
+(define-record-type* <scron-configuration> scron-configuration
+  make-scron-configuration
+  scron-configuration?
+  (scron             scron-configuration-scron    ;package
+                     (default scron))
+  (jobs              scron-configuration-jobs     ;list of <scron-job>
+                     (default '())))
+
+(define-record-type* <scron-job> scron-job
+  make-scron-job
+  scron-job?
+  (schedule scron-job-schedule (default "* * * * *"))
+  (command  scron-job-command  (default '())))
+
+(define (crontab jobs)
+  (apply mixed-text-file "crontab"
+    (concatenate
+      (map
+        (match-lambda
+          (($ <scron-job> schedule command)
+            (list schedule " " command "\n")))
+        jobs))))
+
+(define scron-shepherd-services
+  (match-lambda
+    (($ <scron-configuration> scron jobs)
+     (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
+                                          scron-shepherd-services)))
+                (compose concatenate)
+                (extend (lambda (config jobs)
+                          (scron-configuration
+                           (inherit config)
+                           (jobs (append (scron-configuration-jobs config)
+                                         jobs)))))
+                (default-value (scron-configuration))))
-- 
2.24.0





Information forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 29 Nov 2019 17:55:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 29 12:55:11 2019
Received: from localhost ([127.0.0.1]:33534 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iakU1-00078B-AO
	for submit <at> debbugs.gnu.org; Fri, 29 Nov 2019 12:55:11 -0500
Received: from lists.gnu.org ([209.51.188.17]:55520)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rob@HIDDEN>) id 1iakTw-000782-Tj
 for submit <at> debbugs.gnu.org; Fri, 29 Nov 2019 12:55:07 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:46877)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <rob@HIDDEN>) id 1iakTt-0006eD-KJ
 for guix-patches@HIDDEN; Fri, 29 Nov 2019 12:55:03 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,URIBL_BLOCKED
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <rob@HIDDEN>) id 1iakTo-0003fa-CF
 for guix-patches@HIDDEN; Fri, 29 Nov 2019 12:55:00 -0500
Received: from mout-p-202.mailbox.org ([2001:67c:2050::465:202]:62738)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <rob@HIDDEN>) id 1iakTo-0003VO-1O
 for guix-patches@HIDDEN; Fri, 29 Nov 2019 12:54:56 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org
 [IPv6:2001:67c:2050:105:465:1:1:0])
 (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits))
 (No client certificate requested)
 by mout-p-202.mailbox.org (Postfix) with ESMTPS id 47Phwq4PklzQlBx;
 Fri, 29 Nov 2019 18:54:51 +0100 (CET)
X-Virus-Scanned: amavisd-new at heinlein-support.de
Received: from smtp1.mailbox.org ([80.241.60.240])
 by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173])
 (amavisd-new, port 10030)
 with ESMTP id sC5Oj1X3SuWq; Fri, 29 Nov 2019 18:54:48 +0100 (CET)
From: Robert Vollmert <rob@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] Add scron service.
Date: Fri, 29 Nov 2019 18:53:56 +0100
Message-Id: <20191129175356.12403-1-rob@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2001:67c:2050::465:202
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
Cc: Robert Vollmert <rob@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

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 =3D				\
   %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
=20
+            scron-job
+            scron-job?
+            scron-job-schedule
+            scron-job-command
+
             scron-service-type
             scron-service))
=20
@@ -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:
=20
@@ -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 '())))
=20
 (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))))
=20
-(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)))))))
=20
 (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
--=20
2.24.0





Acknowledgement sent to Robert Vollmert <rob@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#38429; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 8 Dec 2019 03:00:02 UTC

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