unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* mcron job with cd to directory?
@ 2017-05-17 13:12 ng0
  2017-05-17 20:04 ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: ng0 @ 2017-05-17 13:12 UTC (permalink / raw)
  To: help-guix

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,
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"))))
(define %stagit-job2
  #~(job '(next-hour '(4))
           (and
            (chdir "/srv/www/git/ng0")
            (system* "sh" "/root/git_ng0.sh"))))


Of course we all know that the longterm fix is to write
an Guix service for stagit which allows multiple targets,
because stagit's example.sh is just that, an example ;)
-- 
https://pragmatique.xyz
PGP: https://people.pragmatique.xyz/ng0/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mcron job with cd to directory?
  2017-05-17 13:12 mcron job with cd to directory? ng0
@ 2017-05-17 20:04 ` Ludovic Courtès
  2017-05-17 20:15   ` ng0
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2017-05-17 20:04 UTC (permalink / raw)
  To: help-guix

Howdy ng0,

ng0 <ng0@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’.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mcron job with cd to directory?
  2017-05-17 20:04 ` Ludovic Courtès
@ 2017-05-17 20:15   ` ng0
  2017-05-17 21:01     ` Clément Lassieur
  0 siblings, 1 reply; 4+ messages in thread
From: ng0 @ 2017-05-17 20:15 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: help-guix

Ludovic Courtès transcribed 0.9K bytes:
> Howdy ng0,
> 
> ng0 <ng0@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/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mcron job with cd to directory?
  2017-05-17 20:15   ` ng0
@ 2017-05-17 21:01     ` Clément Lassieur
  0 siblings, 0 replies; 4+ messages in thread
From: Clément Lassieur @ 2017-05-17 21:01 UTC (permalink / raw)
  To: ng0; +Cc: help-guix

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-17 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-17 13:12 mcron job with cd to directory? ng0
2017-05-17 20:04 ` Ludovic Courtès
2017-05-17 20:15   ` ng0
2017-05-17 21:01     ` Clément Lassieur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).