Re: How to automatically restart mcron (or register new jobs) on deploy?

2024-07-05 Thread Felix Lechner via
Hi Tomas,

On Fri, Jul 05 2024, Tomas Volf wrote:

> Is there a way to make this happen automatically?

Do the new timers from the Shepherd development branch do that?

Kind regards
Felix



How to automatically restart mcron (or register new jobs) on deploy?

2024-07-05 Thread Tomas Volf
Hello,

I created a new service-type which (among other things) extends
mcron-service-type to register few jobs.  It seems to work, with one exception.
When I deploy the configuration, the mcron jobs are not registered.  They are
not being executed and they are not visible in the output of `herd schedule
mcron'.

They do show up when I either reboot or manually execute `herd restart mcron'.

Is there a way to make this happen automatically?  Having to remember "right,
the jobs were changed, I need to log onto the server and restart mcron" is bit
annoying and I am sure I will forget sooner or later.

Thank you and have a nice weekend,
Tomas Volf

--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.


signature.asc
Description: PGP signature


Re: mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Felix Lechner via
Hi,

> you can find it here
> I've attached my mbsync service
> I just run mbsync as an mcron service.
> +1! I also run it using mcron.
> In my home services I have this:
> I'm doing something similar

First off, thanks for all your responses so far!

On Thu, Feb 22 2024, Emmanuel Beffara wrote:

> the command in the mcron job is called with an incomplete PATH.

Has anyone noticed a similar PATH issue with system Mcron jobs?  I have
to do this inside my Mcron jobs:

(setenv "PATH"
(string-join (list "/run/setuid-programs" (getenv "PATH")) ":"))

Otherwise, the setuid copies of my executables like 'sendmail' are not
available in Mcron jobs.

Also, while I have your attention, my fellow Mcron aficionados, please
feel free to check out this little issue. [1] There goes another
afternoon...

Kind regards
Felix

[1] https://lists.gnu.org/archive/html/bug-mcron/2023-12/msg1.html



Re: mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Emmanuel Beffara
Hi,

De Tanguy LE CARROUR le 22/02/2024 à 14:51:
> Quoting Emmanuel Beffara (2024-02-22 13:37:10)
> > I recently noticed an issue with that: it seems that the command in the 
> > mcron
> > job is called with an incomplete PATH.
> 
> Yes, indeed.
> 
> The "problem" was discussed, among other places, here:
> <https://lists.gnu.org/archive/html/help-guix/2024-01/msg00091.html>.

Ha. I did receive this thread but didn't read it enough to realize this was
actually the cause of my problem (symptom: mail was not fetched automatically
anymore, it turns out the reasons were essentially the same as in your case).

> Long story short: I decided to put (or inject) the full path in all my
> config files.

My current fix is to prefix the job command with “source ~/.profile;” and keep
the config files otherwise unchanged.

Thanks !

-- 
Emmanuel



Re: mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Tanguy LE CARROUR
Hi Emmanuel,


Quoting Emmanuel Beffara (2024-02-22 13:37:10)
> De Carlo Zancanaro le 22/02/2024 à 10:27:
> > On Wed, Feb 21 2024, Felix Lechner via wrote:
> > > Does anyone have an 'mbsync' home service, please? Thanks!
> > I just run mbsync as an mcron service. I have a custom script, because I
> > do some weird stuff to update my mu index afterwards, but it shouldn't
> > be hard to figure out how to call mbsync directly.
> > 
> > In my home services I have this:
> > 
> >(simple-service 'mail-update-script
> >home-mcron-service-type
> >;; Update email every five minutes.
> >(list #~(job '(next-minute '(0 5 10 15 20 25 30 35 40 45 
> > 50 55))
> > "/home/carlo/.local/bin/fetch-mail")))
> > 
> > Obviously this doesn't handle configuring mbsync, which I do outside of
> > my home configuration.
> […]
> I recently noticed an issue with that: it seems that the command in the mcron
> job is called with an incomplete PATH.

Yes, indeed.

The "problem" was discussed, among other places, here:
<https://lists.gnu.org/archive/html/help-guix/2024-01/msg00091.html>.

Long story short: I decided to put (or inject) the full path in all my
config files.

-- 
Tanguy



mcron service and PATH (was: Home service for mbsync?)

2024-02-22 Thread Emmanuel Beffara
Hello,

De Carlo Zancanaro le 22/02/2024 à 10:27:
> On Wed, Feb 21 2024, Felix Lechner via wrote:
> > Does anyone have an 'mbsync' home service, please? Thanks!
> 
> I just run mbsync as an mcron service. I have a custom script, because I
> do some weird stuff to update my mu index afterwards, but it shouldn't
> be hard to figure out how to call mbsync directly.
> 
> In my home services I have this:
> 
>(simple-service 'mail-update-script
>home-mcron-service-type
>;; Update email every five minutes.
>(list #~(job '(next-minute '(0 5 10 15 20 25 30 35 40 45 
> 50 55))
> "/home/carlo/.local/bin/fetch-mail")))
> 
> Obviously this doesn't handle configuring mbsync, which I do outside of
> my home configuration.

I'm doing something similar, with a custom script that calls mbsync and does
some additional stuff for indexing and tagging by notmuch.

I recently noticed an issue with that: it seems that the command in the mcron
job is called with an incomplete PATH. I diagnosed that by creating a
similar mcron job with the command "/usr/bin/env > ~/E". Apparently my user
profile (as defined in .profile, which is managed by guix home) is indeed
inherited by the job, except for PATH which is reset and just contains
/run/current-system/profile/bin.

This is problematic if the job wants to call a command that is not in the
system profile. A workaround would be to define the job with an explicit
reference to a package, like:

 (service
   home-mcron-service-type
   (home-mcron-configuration
 (jobs (list
 #~(job
   '(next-minute (range 0 60 5))
   (string-append #$isync "/bin/mbsync inbox")
   )

but this does not completely solve the issue since PATH is still reset and
any command that is called through mbsync (e.g. through a PassCmd setting)
will fail if it does not have an absolute path.

Is there a proper way to inherit PATH from the user profile in mcron jobs ?

-- 
Emmanuel



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Oleg,


Quoting Oleg Pykhalov (2024-01-15 18:13:13)
> Tanguy LE CARROUR  writes:
> > `mcron` can then find `notmuch`, but `notmuch` has some hooks that depend
> > on other commands; `mbsync` and `afew` in my case. For this, I cannot really
> > provide the full path? 樂 … actually, I could, but then it would be
> > `/home/USER/.guix-home/profile/bin/mbsync`, not the actual path.
> 
> Is the hook a script?  If it is, then the script should have the PATH,
> which can be added to the script itself.

Yes, indeed. Notmuch uses hooks scripts that I provide.
So far, I was relying on `home-xdg-configuration-files-service-type`
to copy them.

```scheme
(service home-xdg-configuration-files-service-type
  `(("notmuch/default/hooks" ,(local-file "tanguy.home/notmuch_hooks" 
#:recursive? #t))
; […]
  ))
```

Now I have to find an easy way to substitute some content in them.
I'll give it a try with `find-files` and `substitute` unless you can
suggest a better way… 爛


> > This should work, but I can help be find it a bit weird, because it
> > propagates to quite a number of files. 
> > And the same goes for `vdirsyncer` that relies on `pass`…
> 
> Is ‘vdirsyncer’ relies on the ‘pass’ by default, or is your
> configuration specific thing?
>
> ‘vdirsyncer’ package recipe should be modified in the first case, to
> make it work for everyone.
> 
> In case of specific configuration a wrapper can be used.

Configuration specific! Fortunately I have a not-yet-submitted home
service for that. So I can easily insert the absolute path! 拾

Regards,

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Nils,


Quoting Nils Landt (2024-01-15 19:11:25)
> 
> > Tanguy LE CARROUR  hat am 15.01.2024 13:30 CET 
> > geschrieben:
> > > If I'm correct, setting the PATH environment variable in the mcron job
> > > should fix it.
> > 
> > You mean inside the `#~(job …)`? Sorry, but… how would you do that? 
> 
> Haven't tried it, but something like:
> 
> #~(job '(next-minute (range 0 60 5)) (string-append #$bash " -c 
> \"PATH=$HOME/.guix-home/profile/bin " #$notmuch "/bin/notmuch new\""))

Thanks. I'll give it a try. But based on Oleg's answer, I might go with
modifying all my config files to substitute absolute paths…

Regards,

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Nils Landt


> Tanguy LE CARROUR  hat am 15.01.2024 13:30 CET 
> geschrieben:
> > If I'm correct, setting the PATH environment variable in the mcron job
> > should fix it.
> 
> You mean inside the `#~(job …)`? Sorry, but… how would you do that? 

Haven't tried it, but something like:

#~(job '(next-minute (range 0 60 5)) (string-append #$bash " -c 
\"PATH=$HOME/.guix-home/profile/bin " #$notmuch "/bin/notmuch new\""))

> And this means that I would have to do it for every single job? 樂

Yes.

> Sounds suboptimal to me.

Agreed! Alternatively, you could install the dependent packages (like pass) in 
guix system, not guix home.

> So I would definitively favour a solution where the PATH is set once and
> for all by Mcron.

I'm pretty sure this does not exist for mcron.



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Oleg Pykhalov
Tanguy LE CARROUR  writes:

> Quoting Oleg Pykhalov (2024-01-15 16:25:27)
>> The Home service matches Guix System in this case, so currently
>> specification of a full path to a binary is required.
>> 
>> It's possible to do in several ways:
>> 
>> 1) Use full path to the binary with ungexp, e.g.
>> 
>> preferred and cleaner:
>> 
>> #$(file-append notmuch "/bin/notmuch")
>> 
>> or:
>> (string-append #$notmuch "/bin/notmuch")
>> 
>> Hint: make sure notmuch is defined, e.g. at the top of a file:
>> 
>> (use-modules (gnu packages mail))
>
> I tried this one! 
> The `string-append` version I mean.
>
> `mcron` can then find `notmuch`, but `notmuch` has some hooks that depend
> on other commands; `mbsync` and `afew` in my case. For this, I cannot really
> provide the full path? 樂 … actually, I could, but then it would be
> `/home/USER/.guix-home/profile/bin/mbsync`, not the actual path.

Is the hook a script?  If it is, then the script should have the PATH,
which can be added to the script itself.

> This should work, but I can help be find it a bit weird, because it
> propagates to quite a number of files. 
> And the same goes for `vdirsyncer` that relies on `pass`…

Is ‘vdirsyncer’ relies on the ‘pass’ by default, or is your
configuration specific thing?

‘vdirsyncer’ package recipe should be modified in the first case, to
make it work for everyone.

In case of specific configuration a wrapper can be used.


Oleg.


signature.asc
Description: PGP signature


Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Oleg,

Quoting Oleg Pykhalov (2024-01-15 16:25:27)
> The Home service matches Guix System in this case, so currently
> specification of a full path to a binary is required.
> 
> It's possible to do in several ways:
> 
> 1) Use full path to the binary with ungexp, e.g.
> 
> preferred and cleaner:
> 
> #$(file-append notmuch "/bin/notmuch")
> 
> or:
> (string-append #$notmuch "/bin/notmuch")
> 
> Hint: make sure notmuch is defined, e.g. at the top of a file:
> 
> (use-modules (gnu packages mail))

I tried this one! 
The `string-append` version I mean.

`mcron` can then find `notmuch`, but `notmuch` has some hooks that depend
on other commands; `mbsync` and `afew` in my case. For this, I cannot really
provide the full path? 樂 … actually, I could, but then it would be
`/home/USER/.guix-home/profile/bin/mbsync`, not the actual path.

This should work, but I can help be find it a bit weird, because it
propagates to quite a number of files. 
And the same goes for `vdirsyncer` that relies on `pass`…

Oh, actually, I've just figured out that this doesn't actually work,
because my `USER` is not the same on all my computers! 
And I cannot rely on `$HOME` because it's not supported by all the
configuration files that are affected.

So I would definitively favour a solution where the PATH is set once and
for all by Mcron.

Regards,

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Oleg Pykhalov
Tanguy LE CARROUR  writes:

> If I'm correct, setting the PATH environment variable in the mcron job
> should fix it.
>
> You mean inside the `#~(job …)`? Sorry, but… how would you do that? 
> And this means that I would have to do it for every single job? 樂
> Sounds suboptimal to me.



> Quoting Tanguy LE CARROUR (2024-01-15 13:30:35)
>> Quoting Nils Landt (2024-01-15 13:03:06)
>> > > Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET
>> > > geschrieben:
>> > > […]
>> > > `mbsync` is in my profile, but Mcron cannot find it.
>> > > Do I have to declare all the required packages… somehow?! 樂
>> > 
>> > That sounds like it's related to this issue I reported:
>> > https://issues.guix.gnu.org/65471
>> 
>> It looks like, indeed!
>
> Actually, there's a "small" difference: I'm not using Debian, but… Guix
> System! 樂

The Home service matches Guix System in this case, so currently
specification of a full path to a binary is required.

It's possible to do in several ways:

1) Use full path to the binary with ungexp, e.g.

preferred and cleaner:

#$(file-append notmuch "/bin/notmuch")

or:
(string-append #$notmuch "/bin/notmuch")

Hint: make sure notmuch is defined, e.g. at the top of a file:

(use-modules (gnu packages mail))


2) Symlink resolving in a Guix profile, e.g.:

"/home/user123/.guix-profile/bin/notmuch"

or

(readlink "/home/user123/.guix-profile/bin/notmuch")


I would recommend for 1) because of reproducibility and easier to track
in future, especially if you have a lot of self managed services.


Oleg.


signature.asc
Description: PGP signature


Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Quoting Tanguy LE CARROUR (2024-01-15 13:30:35)
> Quoting Nils Landt (2024-01-15 13:03:06)
> > > Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET 
> > > geschrieben:
> > > […]
> > > `mbsync` is in my profile, but Mcron cannot find it.
> > > Do I have to declare all the required packages… somehow?! 樂
> > 
> > That sounds like it's related to this issue I reported:
> > https://issues.guix.gnu.org/65471
> 
> It looks like, indeed!

Actually, there's a "small" difference: I'm not using Debian, but… Guix System! 
樂

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Hi Nils,

Quoting Nils Landt (2024-01-15 13:03:06)
> > Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET 
> > geschrieben:
> >
> > ```scheme
> > (gnu packages dav)  ; vdirsyncer
> > (gnu packages mail)  ; notmuch
> > ; […]
> > (service home-mcron-service-type
> > (home-mcron-configuration
> >  (jobs (list
> >  #~(job '(next-minute (range 0 60 5)) (string-append 
> > #$notmuch "/bin/notmuch new"))
> >  #~(job '(next-hour) (string-append #$vdirsyncer 
> > "/bin/vdirsyncer sync"))
> > ```
> > 
> > And now Mcron finds `notmuch` (and `vdirsyncer`), but… Notmuch has hooks
> > that depend on other commands and I now have the following error message
> > in my logs:
> > 
> > ```
> > 2024-01-15 10:20:00 6198 /gnu/store/[…]-notmuch-0.37/bin/notmuch new: 
> > […]/.config/notmuch/default/hooks/pre-new: line 3: mbsync: command not found
> > ```
> > 
> > `mbsync` is in my profile, but Mcron cannot find it.
> > Do I have to declare all the required packages… somehow?! 樂
> 
> That sounds like it's related to this issue I reported:
> https://issues.guix.gnu.org/65471

It looks like, indeed!


> If I'm correct, setting the PATH environment variable in the mcron job
> should fix it.

You mean inside the `#~(job …)`? Sorry, but… how would you do that? 
And this means that I would have to do it for every single job? 樂
Sounds suboptimal to me.

I'll ping #65471 to see if a consensus has been reached. 爛

-- 
Tanguy



Re: "Command not found" when using `home-mcron-service`

2024-01-15 Thread Nils Landt
> Tanguy LE CARROUR  hat am 15.01.2024 10:38 CET 
> geschrieben:
>
> ```scheme
> (gnu packages dav)  ; vdirsyncer
> (gnu packages mail)  ; notmuch
> ; […]
> (service home-mcron-service-type
> (home-mcron-configuration
>  (jobs (list
>  #~(job '(next-minute (range 0 60 5)) (string-append 
> #$notmuch "/bin/notmuch new"))
>  #~(job '(next-hour) (string-append #$vdirsyncer 
> "/bin/vdirsyncer sync"))
> ```
> 
> And now Mcron finds `notmuch` (and `vdirsyncer`), but… Notmuch has hooks
> that depend on other commands and I now have the following error message
> in my logs:
> 
> ```
> 2024-01-15 10:20:00 6198 /gnu/store/[…]-notmuch-0.37/bin/notmuch new: 
> […]/.config/notmuch/default/hooks/pre-new: line 3: mbsync: command not found
> ```
> 
> `mbsync` is in my profile, but Mcron cannot find it.
> Do I have to declare all the required packages… somehow?! 樂

That sounds like it's related to this issue I reported: 
https://issues.guix.gnu.org/65471

If I'm correct, setting the PATH environment variable in the mcron job should 
fix it.



"Command not found" when using `home-mcron-service`

2024-01-15 Thread Tanguy LE CARROUR
Dear Guix,

I had stop using `home-mcron-service` some times ago, for I had
a problem with my home shepherd. Now that this problem seems to be
fixed 爛, I've tried to re-enable `home-mcron-service` and, while it runs,
it cannot find the commands to execute!?

I used to have this config:

```scheme
(service home-mcron-service-type
(home-mcron-configuration
 (jobs (list
 #~(job '(next-minute (range 0 60 5)) "notmuch new")
 #~(job '(next-hour) "vdirsyncer sync")
```

But I now have `notmuch new: sh: line 1: notmuch: command not found` in
my logs.

So, I changed it to:

```scheme
(gnu packages dav)  ; vdirsyncer
(gnu packages mail)  ; notmuch
; […]
(service home-mcron-service-type
(home-mcron-configuration
 (jobs (list
 #~(job '(next-minute (range 0 60 5)) (string-append #$notmuch 
"/bin/notmuch new"))
 #~(job '(next-hour) (string-append #$vdirsyncer 
"/bin/vdirsyncer sync"))
```

And now Mcron finds `notmuch` (and `vdirsyncer`), but… Notmuch has hooks
that depend on other commands and I now have the following error message
in my logs:

```
2024-01-15 10:20:00 6198 /gnu/store/[…]-notmuch-0.37/bin/notmuch new: 
[…]/.config/notmuch/default/hooks/pre-new: line 3: mbsync: command not found
```

`mbsync` is in my profile, but Mcron cannot find it.
Do I have to declare all the required packages… somehow?! 樂

Any help welcome!

Regards,

-- 
Tanguy



Re: Mcron jobs using with-mail-out

2023-05-24 Thread Maxim Cournoyer
Hi Felix,

Felix Lechner via  writes:

> Hi,
>
> Does anyone have a working job specification for Mcron that uses
> "with-mail-out"? [1] I have some trouble providing (mcron redirect)
> inside the gexp. Thanks!

Sorry, I don't, but I'd be interested in a concrete example as well.

-- 
Thanks,
Maxim



Mcron jobs using with-mail-out

2023-05-21 Thread Felix Lechner via
Hi,

Does anyone have a working job specification for Mcron that uses
"with-mail-out"? [1] I have some trouble providing (mcron redirect)
inside the gexp. Thanks!

Kind regards
Felix

[1] 
https://www.gnu.org/software/mcron/manual/mcron.html#index-with_002dmail_002dout



Re: mcron <3 offlineimap

2022-09-21 Thread Sergiu Ivanov
Hi,

zimoun  [2022-09-21T10:31:45+0200]:
> On Sat, 27 Aug 2022 at 10:45, jgart  wrote:
>
>> has anyone tried running offlineimap on a(n) (m)cron?
>
> No.  And I switched from offlineimap to isync (mbsync) for some parts.
> And to public-inbox (so Git) for other parts.

Same thing here (sans public-inbox).  I also found that isync was
considerably faster than offlineimap.

Two years ago I had the impression that offlineimap was in the process
of being abandoned, due in particular to the side note from the
maintainer here: http://www.offlineimap.org/ .  However, when I check
various Git repos today, it seems that offlineimap is still quite alive
and kicking.

-
Sergiu



Re: mcron <3 offlineimap

2022-09-21 Thread zimoun
Hi,

On Sat, 27 Aug 2022 at 10:45, jgart  wrote:

> has anyone tried running offlineimap on a(n) (m)cron?

No.  And I switched from offlineimap to isync (mbsync) for some parts.
And to public-inbox (so Git) for other parts.


Cheers,
simon



mcron <3 offlineimap

2022-08-27 Thread jgart


hi

has anyone tried running offlineimap on a(n) (m)cron?



Help to debug a try with home-mcron-service-type on guix home

2022-06-29 Thread Sébastien Rey-Coyrehourcq


Hi guix !

I'm trying to config a mcron service type for mbsync, something 
simple, but there are few example on the web for the new 
home-mcron-service-type. I try something like this :


(use-modules (gnu packages mail)
(gnu packages tls)
(gnu home services mcron))


(define update-mail-service
 #~(job '(next-minute '(range 0 60 5))
(lambda ()
  (execl (string-append #$isync "/bin/mbsync")
 "mbync"
 "-a"))
"fetch mail"))

(define-public %mail-module
 (home-module
  (list mu
isync
imapfilter
msmtp
gnutls)

  (list
   (simple-service 'isync-mail-config-service
   home-files-service-type
   `(
 (".mbsyncrc" ,(local-file 
 "../config/mail/mbsyncrc"))
 (".msmtprc",(local-file 
 "../config/mail/msmtprc"))
 (".imapfilter/config.lua",(local-file 
 "../config/mail/config.lua"

   (simple-service `mcron-mail-update-service
   home-mcron-service-type
   (list update-mail-service))
   )))

but when i run reconfigure, i have an error in drv compilation :

Backtrace:
  7 (primitive-load 
  "/gnu/store/dpaczpr4j05437bk4dr1snqnfjx9ipfl-mcron-1.2.1/bin/mcron")

In mcron/scripts/mcron.scm:
   103:6  6 (main)
In ice-9/boot-9.scm:
  260:13  5 (for-each #  mcron/scripts/mcron.scm:103:16 (file)> _)

In unknown file:
  4 (eval-string "update-mail-service" #  job-specifier) 74035780>)

In ice-9/boot-9.scm:
  2835:4  3 (save-module-excursion #  ice-9/eval-string.scm:66:9 ()>)

In ice-9/eval-string.scm:
38:6  2 (read-and-eval # #:lang 
_)

In ice-9/eval.scm:
  223:20  1 (proc #  74035780>)

In unknown file:
  0 (%resolve-variable (7 . update-mail-service) 
  #)


ERROR: In procedure %resolve-variable:
Unbound variable: update-mail-service
Backtrace:
  2 (primitive-load 
  "/gnu/store/b3k8pm2gabw29rmb86r5j4j4jzz7847d-mcron-job-builder")

In ice-9/eval.scm:
   619:8  1 (_ #f)
In guix/build/utils.scm:
   762:6  0 (invoke 
   "/gnu/store/dpaczpr4j05437bk4dr1snqnfjx9ipfl-mcron-1.2.1/bin/mcron" 
   "--schedule=20" "prologue" "job")


guix/build/utils.scm:762:6: In procedure invoke:
ERROR:
 1. :
 program: 
 "/gnu/store/dpaczpr4j05437bk4dr1snqnfjx9ipfl-mcron-1.2.1/bin/mcron"

 arguments: ("--schedule=20" "prologue" "job")
 exit-status: 1
 term-signal: #f
 stop-signal: #f

Any help appreciated :) !
Best regards,



signature.asc
Description: PGP signature


Re: Guix home mcron help

2022-06-24 Thread Trev
Quick update:

I was able to get my mcron working in a way that seems to be the proper
"guix home" way. It just took a lot of re-reading, trial & error.

The downside to my solution is that I had to wrap my entire mailsync
module in a #~(job #$(program-file)) gexp.

Here's an example of my solution: https://pastebin.com/f12mvpUz

I hate to admit that I struggled a lot with the documentation for what a
gexp is, how they're meant to be implemented, and what a (job) procedure
will allow given the context of a guix home service.

For example, I couldn't figure out how to store my module & an image
file in the guix store so that I could thereafter load and run the file
with a command such as `guile -s` as the cron job. Or better yet, load the 
module with
`use-modules` from the "program-file" and run the exported functions.

Anyway, I am open to feedback/suggestions. Thanks for reading this :)

Trev  writes:

> Hey guys, 
>
> I am trying to appreciate how to set up a guix home mcron using a separate 
> module that I wrote that exports the job. 
>
> My config lives in ~/.config/guix/home/config.scm 
>
> My cron module lives in ~/.config/guix/home/cron/mailsync.scm 
>
> The mailsync module export this: 
>
> (define-public %mailsync-job
>   #~(job '(next-minute-from
>(next-minute) (range 0 60 15))
>  (lambda ()
>(mailsync-update %mailsync-default-terms)
>(mailsync-notify
> (mailsync-count-new-messages)))
>  "mbsync-nm-job"))
>
> In my home config I am using it like this: 
>
> (home-environment
>  (packages
>   (specifications->packages
>(append %base-packages
>%emacs
>    %multimedia
>%browsers
>%chat-clients
>%devel)))
>  (services
>   (list (service home-mcron-service-type
>  (home-mcron-configuration
>   (jobs (list %mailsync-job)))
>
> The command guix home reconfigure ~/.config/guix/home/config.scm passes 
> without errors but the resulting cron is unhappy when it runs
> because it has lost scope of the module it came from and can't find 
> mailsync-update (or any other definitions from within said module). 
>
> I have attempted to implement with-imported-modules from within the module 
> and from within my home configuration and am not having much
> success. 
>
> Can I get a push? 
>
> Here's a link to the config and module in full: 
> https://gist.github.com/trev-dev/3312444daa75758822c06db5922aac4f 
> -- 
>
> Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206

-- 

Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206


signature.asc
Description: PGP signature


Guix home mcron help

2022-06-23 Thread Trev
Hey guys,

I am trying to appreciate how to set up a guix home mcron using a
separate module that I wrote that exports the job.

My config lives in ~/.config/guix/home/config.scm

My cron module lives in ~/.config/guix/home/cron/mailsync.scm

The mailsync module export this:

#+BEGIN_SRC scheme
(define-public %mailsync-job
  #~(job '(next-minute-from
   (next-minute) (range 0 60 15))
 (lambda ()
   (mailsync-update %mailsync-default-terms)
   (mailsync-notify
(mailsync-count-new-messages)))
 "mbsync-nm-job"))
#+END_SRC

In my home config I am using it like this:

#+BEGIN_SRC scheme
(home-environment
 (packages
  (specifications->packages
   (append %base-packages
   %emacs
   %multimedia
   %browsers
   %chat-clients
   %devel)))
 (services
  (list (service home-mcron-service-type
     (home-mcron-configuration
  (jobs (list %mailsync-job)))
#+END_SRC

The command =guix home reconfigure ~/.config/guix/home/config.scm= passes 
without errors but the resulting cron is unhappy when it runs because it has 
lost scope of the module it came from and can't find =mailsync-update= (or any 
other definitions from within said module).

I have attempted to implement =with-imported-modules= from within the module 
and from within my home configuration and am not having much success.

Can I get a push?

Here's a link to the config and module in full: 
https://gist.github.com/trev-dev/3312444daa75758822c06db5922aac4f

-- 

Trev : 0FB7 D06B 4A2A F07E AD5B  1169 183B 6306 8AA1 D206


signature.asc
Description: PGP signature


Re: How to call a local function from a mcron job?

2020-12-22 Thread EuAndreh via
That makes sense. I'll try it later and report back.

Thanks!



How to call a local function from a mcron job?

2020-11-29 Thread EuAndreh
Hi Guix!

I wrote a Guile function that works like a script that take no arguments
and interacts with the filesystem, something like:

  (define (my-fn)
...)

It is a wrapper over other functions defined in the same file, and calls
them in the right order.

Then I wanted to make this function run as a mcron job, and I tried:

  (define my-fn-job
#(job "* * * * *"
  my-fn))

But that doesn't work. At reconfigure time, Guix complains about not
knowing the variable 'my-fn':

  Unbound variable: my-fn

I tried wrapping it in a '(with-imported-modules ...)' call, but the
code isn't in a module, but in the same file.

I guess that putting all my code from 'my-fn' and all the functions it
calls inlined in a lambda in the job definition would solve it, but it
feels wrong to me.

Is there a way to reference it from the job, without embedding all the
scheme code in the job definition?



Re: A simple battery level alert mcron job for your Guix, v2

2019-07-31 Thread Ricardo Wurmus


Maxim Cournoyer  writes:

> The following mcron job accomplish this.  I've implemented it in Guile
> Scheme this time around and was puzzled that I had to use program-file
> to make it work, otherwise srfi-26's cut would error on undefined symbol
> '<>'.
>
> The problem was that passing the code as a lambda would have the syntax
> imported not a the top level, which is the only valid place to
> define/import syntax definitions, per the Guile manual.  Using
> `program-file' works around that, by placing the logic at the top level
> of a standalone script, while allowing you to define everything at the
> level of your Guix config file.

Ah, thanks for investigating this.  When you first asked about this I
was really quite puzzled.

>(let* ((input-pipe (open-pipe* OPEN_READ
>   #$(file-append acpi "/bin/acpi")))
>   (output (get-string-all input-pipe))
>   (m (string-match "Discharging, ([0-9]+)%" output))
>   (level (and=> m (compose string->number
>(cut match:substring <> 1)
>  (when (and=> level (cut <= <> %min-level))
>(format #t "warning: Battery level is low (~a%)~%" level)
>(invoke #$(file-append beep "/bin/beep") "-r5")))

Perhaps and-let* (SRFI 2) would be of interest here.

-- 
Ricardo




Re: A simple battery level alert mcron job for your Guix, v2

2019-07-31 Thread Maxim Cournoyer
Hello again,

The previously posted battery level alert job had a very annoying
limitation: it would keep beeping until the level of the battery would
have recovered above the defined limit.

We can do much better by stopping the noise as soon as the AC cable has
been plugged in.

The following mcron job accomplish this.  I've implemented it in Guile
Scheme this time around and was puzzled that I had to use program-file
to make it work, otherwise srfi-26's cut would error on undefined symbol
'<>'.

The problem was that passing the code as a lambda would have the syntax
imported not a the top level, which is the only valid place to
define/import syntax definitions, per the Guile manual.  Using
`program-file' works around that, by placing the logic at the top level
of a standalone script, while allowing you to define everything at the
level of your Guix config file.

Here's the new job definition, including an easy way to test it:

#+BEGIN_SRC scheme
(use-modules (gnu packages linux)
 (gnu packages terminals)
 (guix build utils)
 (guix derivations)
 (guix gexp)
 (guix modules)
 (guix store)
 (guix ui))

;;; Helper to build a derivation easily.
(define (build-drv drv)
  (with-store store
(let* ((drv (run-with-store store drv))
   (success? (build-derivations store (list drv
  (when (not success?)
(error "Build failed."))
  (derivation->output-path drv

(define %battery-alert-job
  ;; Beep the system when the battery reaches %MIN-LEVEL or less
  ;; battery percent.
  (program-file
   "battery-alert.scm"
   (with-imported-modules (source-module-closure
   '((guix build utils)))
 #~(begin
 (define %min-level 20)
 (use-modules (guix build utils)
  (ice-9 popen)
  (ice-9 regex)
  (ice-9 textual-ports)
  (srfi srfi-26))
 (setenv "LC_ALL" "C")
 (let* ((input-pipe (open-pipe* OPEN_READ
#$(file-append acpi "/bin/acpi")))
(output (get-string-all input-pipe))
(m (string-match "Discharging, ([0-9]+)%" output))
(level (and=> m (compose string->number
 (cut match:substring <> 1)
   (when (and=> level (cut <= <> %min-level))
 (format #t "warning: Battery level is low (~a%)~%" level)
 (invoke #$(file-append beep "/bin/beep") "-r5")))

;;; Test job
(invoke (build-drv (lower-object %battery-alert-job)))
#+END_SRC

I'll send a patch to document the use of program-file for this use case,
along with this example.

Maxim



A simple battery level alert mcron job for your Guix

2019-07-21 Thread Maxim Cournoyer
If like me, you are using a minimalist WM, you might miss on basic
features such as a battery level gauge.  Having a laptop silently die on
us due to forgetting to plug the AC charger can be frustrating...

So here's a small hack that should at least beep the PC speaker when the
battery goes below 20%.  It relies on "acpi" to get the battery level
and "beep" to make use of the PC speaker.

--8<---cut here---start->8---
(use-service-module
 ...
 base
 mcron
 ...)

(use-package-modules
 ...
 linux
 terminals  ; for "beep"
 ...)

;;; Allow the use of the PC speaker (beep) for any active user.
(define %pcspeaker-beep-rule
  (udev-rule
   "70-pcspkr-beep.rules"
   (string-append "ACTION==\"add\", SUBSYSTEM==\"input\", "
  "ATTRS{name}==\"PC Speaker\", ENV{DEVNAME}!=\"\", "
  "TAG+=\"uaccess\"")))

(define %battery-alert-job
  #~(job '(next-minute (range 0 60 1))
 "(( $(acpi | cut -d',' -f2 | tr -d ' %') < 20 )) && beep -r5"))

(operating-system
 ...
 (packages (cons* ...
  acpi beep ;for the battery alert mcron job
  %base-packages))

 (services
  (cons*
   (service mcron-service-type
(mcron-configuration (jobs (list %battery-alert-job
...
   (modify-services %desktop-services
(udev-service-type config =>
   (udev-configuration
(inherit config)
(rules (cons* %pcspeaker-beep-rule
  (udev-configuration-rules config)
--8<---cut here---end--->8---

One caveat: on my laptop at least, the mute button silences even the PC
speaker, leaving some room for more surprise shutdowns.

Have fun,

Maxim



Re: Debugging an mcron job

2019-04-01 Thread Jack Hill

On Mon, 1 Apr 2019, Ludovic Courtès wrote:


Jack Hill  skribis:

I've solved this for my service by adding SSL_CERT_DIR to the environment:

https://gitlab.oit.duke.edu/jackhill/guix-at-duke/blob/a9674ec7b0decac94745c91df886817e2fc8a91b/guix-at-duke/services/endpoint-management.scm

Is that a reasonable solution?


I’m (very) late to the party but what you did looks like the right thing
to me.


No worries, I still find the sanity check helpful.


PS: Good to see you’re building interesting stuff with this!


Me too :) I've really enjoyed working with the Guix and mcron building 
blocks.


Best,
Jack

Re: Debugging an mcron job

2019-04-01 Thread Ludovic Courtès
Hello,

Jack Hill  skribis:

> On Tue, 12 Mar 2019, Jack Hill wrote:
>
>> I've figured out what was going wrong with my job (by redirecting
>> the output to a file). It couldn't verify the remote host's
>> certificate:
>>
>> urllib2.URLError: > certificate verify failed (_ssl.c:726)>
>>
>> Now to figure out why. I have nss-certs in my system packages.
>
> I've solved this for my service by adding SSL_CERT_DIR to the environment:
>
> https://gitlab.oit.duke.edu/jackhill/guix-at-duke/blob/a9674ec7b0decac94745c91df886817e2fc8a91b/guix-at-duke/services/endpoint-management.scm
>
> Is that a reasonable solution?

I’m (very) late to the party but what you did looks like the right thing
to me.

Ludo’.

PS: Good to see you’re building interesting stuff with this!



Re: Debugging an mcron job

2019-04-01 Thread Ludovic Courtès
Hello,

Jack Hill  skribis:

> On Tue, 12 Mar 2019, Jack Hill wrote:
>
>> I've figured out what was going wrong with my job (by redirecting
>> the output to a file). It couldn't verify the remote host's
>> certificate:
>>
>> urllib2.URLError: > certificate verify failed (_ssl.c:726)>
>>
>> Now to figure out why. I have nss-certs in my system packages.
>
> I've solved this for my service by adding SSL_CERT_DIR to the environment:
>
> https://gitlab.oit.duke.edu/jackhill/guix-at-duke/blob/a9674ec7b0decac94745c91df886817e2fc8a91b/guix-at-duke/services/endpoint-management.scm
>
> Is that a reasonable solution?

I’m (very) late to the party but what you did looks like the right thing
to me.

Ludo’.



Re: Debugging an mcron job

2019-03-12 Thread Jack Hill

On Tue, 12 Mar 2019, Jack Hill wrote:

I've figured out what was going wrong with my job (by redirecting the output 
to a file). It couldn't verify the remote host's certificate:


urllib2.URLError: verify failed (_ssl.c:726)>


Now to figure out why. I have nss-certs in my system packages.


I've solved this for my service by adding SSL_CERT_DIR to the environment:

https://gitlab.oit.duke.edu/jackhill/guix-at-duke/blob/a9674ec7b0decac94745c91df886817e2fc8a91b/guix-at-duke/services/endpoint-management.scm

Is that a reasonable solution?

Best,
Jack



Re: Debugging an mcron job

2019-03-12 Thread Jack Hill
I've figured out what was going wrong with my job (by redirecting the 
output to a file). It couldn't verify the remote host's certificate:


urllib2.URLError: 

Now to figure out why. I have nss-certs in my system packages.

Best,
Jack




Debugging an mcron job

2019-03-11 Thread Jack Hill

Hi Guix,

I'm looking for help or tips on debugging an mcron job. My goal is to run 
a site-specific telemetry script that I have packaged [0] in my channel. 
The script collects some information and sends it to a remote server. I am 
trying to run the script as an mcron job via a service I created in my 
channel [1].


[0] 
https://gitlab.oit.duke.edu/jackhill/guix-at-duke/blob/0ed0a8e7530ef32b9e268d43b36944e38defa5f1/guix-at-duke/packages/endpoint-management.scm#L98-140
[1] 
https://gitlab.oit.duke.edu/jackhill/guix-at-duke/blob/0ed0a8e7530ef32b9e268d43b36944e38defa5f1/guix-at-duke/services/endpoint-management.scm

So far, this looks good, and after pulling my channel, reconfiguring, and 
restarting mcron, I can see my job in herd schedule mcron:


"""
# herd schedule mcron
Tue Mar 12 00:51:00 2019 -0400
/gnu/store/61692zjpkhy3jqv4a7jk1k8a14k6yn8k-planisphere-report-0-0.1b606af/bin/planisphere-report
…
"""

However, this doesn't appear to work because after the appointed time, the 
remote server is not updated. If I run the planisphere-report command by 
hand, the remote server is updated.


If I replace the planisphere-report command in my job with 
"/run/current-system/profile/bin/touch /tmp/test-file", test-file is 
indeed touched, so I know that the jobs are running.


Being fairly new to Guix, and extremely new to mcron, I don't know how to 
debug further. Are jobs run in such a way that they don't have network 
access? How can I see any errors or output?


Best,
Jack

P.S. I'm happy to accept any comments about how to improve the code in my 
channel as well ☺.

Re: mcron

2018-08-05 Thread Pierre Neidhardt
Yes, Vixie syntax is supported there too!
See "(mcron) Vixie Syntax".

But if you can grasp the Lisp syntax instead, I'd recommend you for it, it's
much more flexible.  After all, it's the sole raison-d'être of mcron with regard
to cron :)

I think your solution to "every N minute" is correct.

Cheers!
-- 
Pierre Neidhardt


signature.asc
Description: PGP signature


Re: mcron

2018-08-04 Thread Benjamin Slade
Many thanks, Pierre.

Can one also mix Vixie-style things in `~/.config/cron/` ?

It probably doesn't matter since I think I've figured out mcron native
syntax.  I was looking everywhere in "(mcron) Top" for an example of "do
X every N minutes", but finally figured out that this works (at least I
hope so):

--8<---cut here---start->8---
(job '(next-minute (range 0 60 5)) "dosomethingevery5minutes")
(job '(next-minute (range 0 60 10)) "dosomethingevery10minutes")
--8<---cut here---start->8---

--
Benjamin Slade - https://babbagefiles.xyz
  `(pgp_fp: ,(21BA 2AE1 28F6 DF36 110A 0E9C A320 BBE8 2B52 EE19))
'(sent by mu4e on Emacs running under GNU/Linux . https://gnu.org )
   `(Choose Linux ,(Choose Freedom) . https://linux.com )



Re: mcron

2018-08-04 Thread Pierre Neidhardt
No, mcron at the user-level is even simpler, simply tweak your configuration
file and start `mcron`.

Example job in ~/.config/cron/job.guile:
--8<---cut here---start->8---
(job '(next-hour (range 0 24 3)) "updatedb")
--8<---cut here---end--->8---

Once mcron is running, you can test the schedule by calling `mcron --schedule=5`
to list the 5 next scheduled jobs.

Have a look at "(mcron) Top", it's a very short read ;)

-- 
Pierre Neidhardt


signature.asc
Description: PGP signature


Re: mcron

2018-08-04 Thread Benjamin Slade
On 2018-08-04T02:44:24-0600, Pierre Neidhardt  wrote:

 > Not sure I can help much here because I personally run help cron from my user
 > session, i.e. with "mcron &" in my ".profile".  I declare the jobs in
 > "~/.config/cron/job.guile".

 > Maybe you could try that for the user-level jobs and see if it works in that 
 > condition?

Thanks, Pierre. What is the procedure for declaring jobs in
`~/.config/cron/job.guile` ? For the `/etc/config.scm` method, as far as
I understand it, the jobs need defining and then enabling/calling. Does
it work for the same for the user session cron in `~/.config/cron/job.guile` ?

thanks,
  ---Ben
-- 
Benjamin Slade - https://babbagefiles.xyz
  `(pgp_fp: ,(21BA 2AE1 28F6 DF36 110A 0E9C A320 BBE8 2B52 EE19))
'(sent by mu4e on Emacs running under GNU/Linux . https://gnu.org )
   `(Choose Linux ,(Choose Freedom) . https://linux.com )



Re: mcron

2018-08-04 Thread Pierre Neidhardt
Not sure I can help much here because I personally run help cron from my user
session, i.e. with "mcron &" in my ".profile".  I declare the jobs in
"~/.config/cron/job.guile".

Maybe you could try that for the user-level jobs and see if it works in that 
condition?

-- 
Pierre Neidhardt


signature.asc
Description: PGP signature


mcron

2018-08-03 Thread Benjamin Slade
nnI'm having trouble getting mcron to work. I have configured it in
/etc/config.scm similarly to the example given in the manual, but it the
mcron service seems to immediately stop. I've tried `sudo herd enable
mcron` and `sudo herd start mcron`, which work, but then when I check
its status, I find mcron is disabled and not running.

My /etc/config.scm looks like this:

`
;; This is an operating system configuration template
;; for a "desktop" setup with GNOME and Xfce where the
;; root partition is encrypted with LUKS.

(use-modules (gnu) (gnu services ssh) (gnu services mcron) (gnu system nss) 
(gnu packages lisp) (gnu packages wm) (gnu packages linux)
(gnu packages guile) (gnu packages backup))
(use-service-modules desktop networking)
(use-package-modules certs gnome wm base idutils xorg)

(define updatedb-job
  ;; Run 'updatedb' at 3AM every day.  Here we write the
  ;; job's action as a Scheme procedure.
  #~(job '(next-hour '(3))
 (lambda ()
   (execl (string-append #$findutils "/bin/updatedb")
  "updatedb"
  "--prunepaths=/tmp /var/tmp /gnu/store"

(define garbage-collector-job
  ;; Collect garbage 5 minutes after midnight every day.
  ;; The job's action is a shell command.
  #~(job "5 0 * * *";Vixie cron syntax
 "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.
  #~(job '(next-minute-from (next-hour '(12 19)) '(15))
 (string-append #$idutils "/bin/mkid src")
 #:user "emacsomancer"))

(define mbsync-mail-fetch-emacsomancer
  ;; fetch mail via isync/mbsync for mu/mu4e every 10 minutes
  #~(job "5/* * * * *"  ;Vixie cron syntax
 "/home/emacsomancer/.guix-profile/bin/mbsync -a"
 #:user "emacsomancer"))

(define test-emacsomancer
  ;; fetch mail via isync/mbsync for mu/mu4e every 10 minutes
  #~(job "1/* * * * *"  ;Vixie cron syntax
 "/home/emacsomancer/.guix-profile/bin/touch /home/emacsomancer/hello"
 #:user "emacsomancer"))


(operating-system
  (host-name "guixy")
  (timezone "US/Mountain")
  (locale "en_GB.utf8")

  ;; Use the UEFI variant of GRUB with the EFI System
  ;; Partition mounted on /boot/efi.
  ;; -> actually using BIOS because guixsd 0.15 live usb didn't probe efi 
;  (bootloader (grub-configuration (device "/dev/sda")))
  (bootloader (bootloader-configuration
(bootloader grub-bootloader)
(target "/dev/sda")))

  ;; Specify a mapped device for the encrypted root partition.
  ;; The UUID is that returned by 'cryptsetup luksUUID'.
  (mapped-devices
   (list (mapped-device
  (source (uuid "e33cc543-9aa9-467a-a9e8-96e1f092b866"))
  (target "guiksdelux")
  (type luks-device-mapping))
 ;; (mapped-device
 ;;  (source (uuid "7c97b263-4adc-b4e9-a1d7-9d3de8eb9694"))
 ;;  (target "guix-home")
 ;;  (type luks-device-mapping))
  ))

  (file-systems (cons* (file-system
   (device (uuid "18c93271-4fcd-484b-ac1a-f4670b6d2b7c" 
'ext4))
   (mount-point "/")
   (type "ext4"))
  (file-system
(device "/dev/mapper/guiksdelux")
(mount-point "/home")
(type "ext4")
(dependencies mapped-devices))
; (file-system
;(device "/dev/mapper/guix-home")
;(mount-point "/home")
;(type "ext4")
;(dependencies mapped-devices))
;  (file-system
; (device (uuid "35ee1733-b91f-4bbc-3bdc-86b5bd25489f" 
'ext2))
; (mount-point "/boot")
; (type "ext2"))
;   (file-system
; (device (uuid "F1D1-FC28" 'fat))
; (mount-point "/boot/efi")
; (type "vfat"))
   %base-file-systems))

  (users (cons (user-account
(name "emacsomancer")
;(comment "")
(group "users")
(supplementary-groups '("wheel" "netdev"
"audio" "video"))
(home-directory "/home/emacsomancer"))
   %base-user-accounts))

  ;; Add GNOME and

Re: Error with mcron-configuration

2018-07-09 Thread Clément Lassieur
Jone  writes:

> *> But only it still does not work!*
>
> With current system version all Ok:
>
> #> sudo herd status mcron
> Status of mcron:
>   It is started.
>   Running value is 298.
>   It is enabled.
>   Provides (mcron).
>   Requires (user-processes).
>   Conflicts with ().
>   Will be respawned.
>
> ps ax | grep mcron
>   298 ?Ssl    0:00
> /gnu/store/9dl8l4krszdd1dhaw94da0nv28ap8dvp-mcron-1.1.1/bin/mcron
> /gnu/store/vvf3frpvrffpchbd3xxlq8kmnxsywja6-mcron-job
> /gnu/store/jv9asgfm82f6k7srwxy6bf9ckk70z270-mcron-job
> /gnu/store/n4jbzmm6ihv70dd8j2ba9501hxs3q9ar-mcron-job
> /gnu/store/2yql34psrh6iiyczs48hj7pw5bgv6gh6-mcron-job
>   722 pts/0S+ 0:00 grep mcron

Hi Jone,

The --schedule option will help you debugging it.

You can do for example:

/gnu/store/9dl8l4krszdd1dhaw94da0nv28ap8dvp-mcron-1.1.1/bin/mcron \
/gnu/store/vvf3frpvrffpchbd3xxlq8kmnxsywja6-mcron-job \
/gnu/store/jv9asgfm82f6k7srwxy6bf9ckk70z270-mcron-job \
/gnu/store/n4jbzmm6ihv70dd8j2ba9501hxs3q9ar-mcron-job \
/gnu/store/2yql34psrh6iiyczs48hj7pw5bgv6gh6-mcron-job --schedule=10

It will compute the times the commands would be run and prints the
information to the screen, and then immediately exits.

See https://www.gnu.org/software/mcron/manual/mcron.html#Invoking-mcron.

Clément



Re: Error with mcron-configuration

2018-07-09 Thread Jone
*> But only it still does not work!*

With current system version all Ok:

#> sudo herd status mcron
Status of mcron:
  It is started.
  Running value is 298.
  It is enabled.
  Provides (mcron).
  Requires (user-processes).
  Conflicts with ().
  Will be respawned.

ps ax | grep mcron
  298 ?Ssl0:00
/gnu/store/9dl8l4krszdd1dhaw94da0nv28ap8dvp-mcron-1.1.1/bin/mcron
/gnu/store/vvf3frpvrffpchbd3xxlq8kmnxsywja6-mcron-job
/gnu/store/jv9asgfm82f6k7srwxy6bf9ckk70z270-mcron-job
/gnu/store/n4jbzmm6ihv70dd8j2ba9501hxs3q9ar-mcron-job
/gnu/store/2yql34psrh6iiyczs48hj7pw5bgv6gh6-mcron-job
  722 pts/0S+ 0:00 grep mcron


Re: Error with mcron-configuration

2018-07-07 Thread Pierre Neidhardt

Jone  writes:

> (use-modules
>  ...
> (gnu services mcron);; ← manual
>  ...
> (define fstrim-job  ;; ← manual
>   #~(job "10 10 * * 6"
>  "fstrim -a"))
> ...
> (services (cons*
>  ...
>   (mcron-service-type (mcron-configuration (jobs (list fstrim-job))))  ;; ←
> but here the question
>  ...

Did you use `mcron-service' around `mcron-service-type'?

>  ...
> (mcron-service (mcron-configuration (jobs (list fstrim-job  ;; ← manual
>  ...

`mcron-service' takes a list of jobs as argument, not an mcron-configuration.

From the manual:


--8<---cut here---start->8---
 -- Scheme Procedure : mcron-service JOBS [#:mcron MCRON]
 Return an mcron service running MCRON that schedules JOBS, a list
 of gexps denoting mcron job specifications.

 This is a shorthand for:
  (service mcron-service-type
   (mcron-configuration (mcron mcron) (jobs jobs)))
--8<---cut here---end--->8---

So for you needs you'd need something like:

--8<---cut here---start->8---
(services (cons*
  (mcron-service (list fstrim-job))
  ...)
--8<---cut here---end--->8---

Hope that helps! :)

-- 
Pierre Neidhardt

Sorry, no fortune this time.


signature.asc
Description: PGP signature


Re: Error with mcron-configuration

2018-07-06 Thread Carlo Zancanaro

Hey Jone!


...
  (mcron-service-type (mcron-configuration (jobs (list 
  fstrim-job

...


This is close, but very slightly wrong. `mcron-service-type` isn't 
a procedure, so you can't call it like that. You have to use 
`service`:


 (service mcron-service-type
  (mcron-configuration (jobs (list fstrim-job

The manual instead uses the `mcron-service` procedure, which I can 
see you tried below...



...
  (mcron-service (mcron-configuration (jobs (list fstrim-job
...


... but in this case, you need to not wrap the jobs in 
`mcron-configuration`. So something like this should work:


 (mcron-service (list fstrim-job))

This is outlined in the manual in (guix) Scheduled Job Execution. 
Were you looking elsewhere in the manual for your examples? If 
there's something that pointed you in the wrong direction, please 
let me know where so I can fix it up.


I hope that helps!

Carlo


signature.asc
Description: PGP signature


Re: mcron or mcron2?

2017-11-23 Thread Leo Famulari
On Thu, Nov 23, 2017 at 11:02:48AM -0600, Caleb Herbert wrote:
> On Thu, 2017-11-23 at 10:01 -0500, Leo Famulari wrote:
> > The GuixSD mcron service uses mcron2, so I think that is probably the
> > best one :)
> 
> Which is more likely to work on a foreign distro?  (Trisquel.)

I'm not sure, because I haven't tried using it in that context.

You could take a look at which version is provided by Trisquel (assuming
they offer mcron), and use that one, since it is probably the best
tested on Trisquel.


signature.asc
Description: PGP signature


Re: mcron job with cd to directory?

2017-05-17 Thread Clément Lassieur
ng0 <n...@pragmatique.xyz> writes:

> Ludovic Courtès transcribed 0.9K bytes:

>> Something like:
>> 
>>   #~(job '(next-hour '(4))
>>   (lambda ()
>> (chdir …)
>> (system* …)))
>> 
>> See 
>> <https://www.gnu.org/software/guix/manual/html_node/Scheduled-Job-Execution.html>.
>> 
>> Ludo’.
>> 
>
> Thanks! This fixed at least the respawn-death of mcron. Now I just have to
> see if it does what I want.

I have found the '--schedule' option of mcron very useful for debugging.
Maybe it'll help you to see if it does what you want.

> But it's good to know that it is that easy.



Re: mcron job with cd to directory?

2017-05-17 Thread ng0
Ludovic Courtès transcribed 0.9K bytes:
> Howdy ng0,
> 
> ng0 <n...@pragmatique.xyz> skribis:
> 
> > Does someone know how you could re-create this:
> >
> > (crontab -l of root)
> > # Regnerate stagit indexes every hour:
> > 0 * * * * (cd /var/www/git && echo `pwd` && /root/git_pragmatique_xyz.sh)
> >
> > in mcron?
> >
> > I have some cronjobs where the initial
> > current-working-dir must be a specific directory.
> >
> > I think I am missing (lambda) in what I have written below,
> 
> Indeed you are!  :-)
> 
> > but the mcron documentation just
> >
> > (define %stagit-job1
> >   #~(job '(next-hour '(4))
> >(and
> > (chdir "/srv/www/git/pragmatique")
> > (system* "sh" "/root/git_pragmatique.xyz.sh"
> 
> Something like:
> 
>   #~(job '(next-hour '(4))
>   (lambda ()
>     (chdir …)
> (system* …)))
> 
> See 
> <https://www.gnu.org/software/guix/manual/html_node/Scheduled-Job-Execution.html>.
> 
> Ludo’.
> 

Thanks! This fixed at least the respawn-death of mcron. Now I just have to
see if it does what I want.
But it's good to know that it is that easy.
-- 
https://pragmatique.xyz
PGP: https://people.pragmatique.xyz/ng0/



Re: mcron job with cd to directory?

2017-05-17 Thread Ludovic Courtès
Howdy ng0,

ng0 <n...@pragmatique.xyz> skribis:

> Does someone know how you could re-create this:
>
> (crontab -l of root)
> # Regnerate stagit indexes every hour:
> 0 * * * * (cd /var/www/git && echo `pwd` && /root/git_pragmatique_xyz.sh)
>
> in mcron?
>
> I have some cronjobs where the initial
> current-working-dir must be a specific directory.
>
> I think I am missing (lambda) in what I have written below,

Indeed you are!  :-)

> but the mcron documentation just
>
> (define %stagit-job1
>   #~(job '(next-hour '(4))
>(and
> (chdir "/srv/www/git/pragmatique")
> (system* "sh" "/root/git_pragmatique.xyz.sh"

Something like:

  #~(job '(next-hour '(4))
  (lambda ()
(chdir …)
(system* …)))

See 
<https://www.gnu.org/software/guix/manual/html_node/Scheduled-Job-Execution.html>.

Ludo’.